Friday, January 25, 2008

jBPM ant task to deploy a process definition to a running server

I've been working on jBPM integration into JBossESB to do Service Orchestration, and I created a new ant task to deploy a process definition to a running instance of jBPM. When I say a running instance I mean an instance that deploys the jBPM-console. The jBPM-console ships with a DeployerServlet which is used by the jBPM eclipse plugin to deploy process definitions. The ant task is called "DeployProcessToServerTask" and it uses the very same servlet. The java code for the task has been attached to jira JBPM-1117 so it should hopefully make it into SVN soon.

To use the DeployProcessToServer Task you need to define a new task using the taskdef command

<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
<classpath refid="exec-classpath"/>
</taskdef>

So here I defined a task called 'deployToServer', but you can call it whatever you want. The classpath should obviously point to the jar containing this class. The 'deployToServer' can either deploy a Process Archive (PAR), which is a zip file containing the files you want to deploy, or you can specify a set of files which it will zip up and deploy for you. You can use the following attributes and subelements:







Attribute DescriptionDefault value
processThe location of process archive-
servernameThe name of the server which is used to build the deployment urllocalhost
serverportThe port to which the http protocol is bound8080
serverdeployerThe address of the deployer servlet/jbpm-console/upload
debugDebug flag which, if set, writes out a debug.par zip file. This is especially useful if fileSet subelements are used, so you can check what gets loaded to the server-
SubElement DescriptionDefault value
fileSetA fileSet element-


The following xml fragment deploys all the files in the processDefinition directory to the server

<target name="deployProcess" description="deploys the process definition">
<echo>Deploy the process definition</echo>
<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
<classpath refid="exec-classpath"/>
</taskdef>
<deployToServer>
<fileset dir="${basedir}/processDefinition" includes="*"/>
</deployToServer>
</target>

Or if you already have a par archive ready to go you could reference that

<target name="deployProcess" description="deploys the process definition">
<echo>Deploy the process definition</echo>
<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
<classpath refid="exec-classpath"/>
</taskdef>
<deployToServer process="${build}/process.par"/>
</target>

6 comments:

jeremyrdavis said...

Nice work!

I can use this.

web designer said...

nice post

jBPM Fan said...

I have authentication configured in my jbpm-console. How can I use this ant script with it?

Kurt Stam said...

You'll need to add some code for the authentication, you can probably lift it from the jBPM Designer plugin code, which is doing the very same thing.

--Kurt

Andre said...

Hi Kurt,

thanks for this!

Just another question: is there any chance to deploy processes to jbpm (installed within the jboss esb) without the server running? I would need that for installation procedures at the customers sites. Otherwise the installation needs to include a complete jboss as boot, then the ant script running and a shutdown of the server. Also, the data directory should not be deleted, which is sometimes necessary to get a clean state for the application server.

Any idea? Or did I get something completely wrong? I couldn't find so far a "usual" offline deployment procedure for jbpm processes (like putting the .par file into a deploy directory).

Thanks,

Andre

Kurt Stam said...

If you *don't* use an embedded database you should be able to use

http://docs.jboss.com/jbpm/v3/userguide/jpdl.html#deployingaprocessarchiveNote that the class got renamed

http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4078036#4078036-K