JBPM – RESTFUL Integration
JBPM is a Business Process Management suite supported by JBoss. Normally popular as an embeddable Business process management tool, very less is known about its integration capabilities. JBPM exposes a complete set of RESTful services with which you can do a number of operations like Create a new process, retrieve tasks and so on. This article is aimed at giving you a conceptual idea of the same. For the client side, we will be using Grails Framework. Grails is a rapid application development framework by Spring Source community. We are assuming that you have a working JBPM Installation running on top of JBoss Application Server.
Assuming you have installed your server on localhost, the rest services are available on the following URL: http://localhost:8080/gwt-console-server/rs/server/resources. You can checkout the list of the services available. Please note the response of these services are in JSON format. You can use a JSON reader or similar API to parse the same.
Services are categories into the following
- Server Info: These services can give you an idea about the server status and resources. Information like which plugins are available is also provided
- Process Management: You can create processes, get installed processes etc easily from Here. For example a call to /gwt-console-server/rs/process/definitions will return you the list of installed processes on the server
- Task Lists and Task Management: These will help you in understanding what tasks are available. Also available are ways to close or assign a task.
- User Management: Users, roles, groups, members etc can be retrieved using this group of service
- Process Engine: Process Engine calls can be used to deploy, undeploy, suspend processes
- Form Processing: Can be used to retrieve and complete forms.
For the sake of understanding, Let me show you how you can retrieve a group of processes on a server
def processes=new java.util.HashMap();
HTTPBuilder http = new HTTPBuilder(“http://localhost:8080”);
http.getAuth().basic(username,password);
http.request( Method.GET, ContentType.JSON) { req ->
uri.path = '/gwt-console-server/rs/process/definitions'
req.getParams().setParameter("http.connection.timeout",new Integer(5000));
req.getParams().setParameter("http.socket.timeout",new Integer(5000));
response.success = { resp, json ->
System.out.println(json);
processes.put(it,json.definitions)
}
}
The above code creates a new HTTPBuildr and connects to localhost on port 8080. After that it makes a REST call to /gwt-console-server/rs/process/definitions and retrieves the installed processes as JSON. The same are placed in the HashMap called processes and then passed to the appropriate view for rendering.
Hope this tutorial was helpful. If you need more information on how to work with tasks and forms please refer to the available documentation or drop in a comment to me.




