JBPM – RESTFUL Integration

Submitted by Abhishek on Tue, 2011-07-26 11:13
jbpm.org

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.


Abhishek Mishra
Good experience in working with BPM technologies like Savvion, JBPM. Founder and Chief Editor of BPMGeek.com. Founder of Savvion Business Manager Mobility Framework Savmobify| View my BPMGeek Profile
|

About BPMGeek

BPMGeek is an initiative to collaborate and communicate with the growing Business process management community out there. The goal is to help developers connect with experts, ask questions, post their learning and get understanding of BPM Concepts. Often tool specific knowledge of niche areas end up developers perplexed and confused - especially when there are very less number of resources available. We will be coming up several several new features. Have a look at our Roadmap here

BPMGeek is an independent entity not associated with any Product. All BPM product professionals are invited to contribute. The Logos and Names used across the site belong to their respective owners. The viewpoints mentioned by Individual contributors are their own. BPMgeek cannot be held liable for any issues arising out of it.