Red Hat MAP – JBoss BPM Suite Integration using Sync Framework

May 26, 2017
Tags: ,


For mobile users who require tasks, information or status updates asynchronously without requiring to explicitly request it, by for example pressing a refresh button, Red Hat MAP provides a very useful built in MBaaS service for this purpose – the Sync framework. This framework makes it possible to keep a mobile app in sync with data modifications made on the server and vice versa, hence keeping two separate data stores synchronized, albeit not in real time. For personnel who work according to a semi-automated process where certain tasks are performed manually, such as collecting data from a customer or traveling to a work site, Red Hat JBoss BPM Suite together with Red Hat MAP provide an excellent means to combine these needs.


The following figure shows the architecture for integrating Red Hat MAP with Red Hat JBoss BPM Suite:


  1. The Mobile App uses the sync framework to regularly check for updates to the Task Collection
  2. The Sync framework checks the collection for updates
  3. A callback through the $fh.sync API is made to the Cloud App
  4. The Cloud App calls the fh-connector-bpm which is deployed as an MBaaS service on Red Hat MAP and provides a REST client to Red Hat JBoss BPM Suite
  5. The connector calls Red Hat JBoss BPM Suite to retrieve the latest processes and tasks
  6. The Cloud App updates the Task Collection
  7. The sync framework propagates the updated collection and stores in the local Task Collection in the Mobile App

Mobile app displaying tasks from Red Hat JBoss BPM Suite

Task data retrieved from Red Hat JBoss BPM Suite can be displayed for example as cards in the mobile app.
The end user can interact with Red Hat JBoss BPM Suite through the mobile app by releasing, starting or completing tasks.
Hence, an action made by the user in the mobile app will affect the state in the process running in Red Hat JBoss BPM Suite
and thus advance the process to the next step.

Mobile app displaying an in-queue with tasks from Red Hat JBoss BPM Suite

The Mobile App can display an in-queue that gets updated when a process running in Red Hat JBoss BPM Suite creates new tasks.
New tasks that are not already claimed by anyone will get pushed to the mobile app through the Sync framework and be presented in a scrollable list. Hence, a team of users can use Red Hat JBoss BPM Suite’s claim function through the mobile app to manually reserve a task to work on. This will remove the task from the in queue until it’s either completed or released back to the queue. All of these operations on the task can be made through the mobile app.


To make a mobile app getting regular updates on changes made in tasks and processes in Red Hat JBoss BPM Suite,
the $fh.sync framework is used together with the fh-connector-bpm.
Using the $fh.sync.globalInterceptRequest function with a globalRequestInterceptor that calls the connector on each sync cycle and then stores the result in a Mongo DB collection allows the mobile app to asynchronously retrieve the latest Red Hat JBoss BPM Suite process and task updates and present these to the user.

The following code example shows the globalRequestInterceptor in the Cloud App deployed on Red Hat MAP:

var $fh = require('fh-mbaas-api');

var globalRequestInterceptor = function(dataset_id, params, cb) {
 // This function will intercept all sync requests.

console.log('Intercepting request for dataset', dataset_id, 'with params', params);
 "guid": "guid of connector",
 "path": "/bpm/runtimeTaskQuery",
 "method": "POST",
 "headers": {
 "Content-Type" : "application/json"
 "params": {
  "params": {"username": "BPM username", "password": "BPM password", "ip": "BPM ip", "port": "BPM port"}
 function(err, body, response) {
  if ( err ) {
   console.log('service call failed - err : ' + err);
  } else {
   var options = {
  "act": "update",
  "type": "Name of collection",
  "guid": "GUID of document",
  "fields": {"Field name in document": JSON.stringify(body)}
  fh.db(options, function (err, data) {
   if (err) {
    console.error("Error " + err);
   } else {
    console.log("Updated document with BPM data");

return cb(null);


Note that in order to reduce amount of data to be retrieved by the mobile app, all updates should be made to the same document, hence, overwriting the previous update.
With this, the mobile app can use the $fh.sync API with the collection name as dataset Id and subscribe to updates in Red Hat JBoss BPM Suite process instances and tasks.
The following code example shows how to set up the sync framework in a mobile app:

var datasetId = "Name of collection";

"do_console_log" : false,
"storage_strategy" : "dom",


$fh.sync.notify(function(notification) {


//res is a JSON object
for(var key in res){
// Unique Id of the record, used for read, update & delete operations (string).
var uid = key;
// Record data, opaque to sync service.
var rawdata = res[key].data;

var data = JSON.parse(rawdata."Field name in document").taskInfoList;
data.uid = uid;

$scope.taskInfoList = data;

var hash = res[key].hash;

function(code, msg){
console.log("error: " + code + ' : ' + msg);

The mobile app’s UI can be updated asynchronously every time there is a change in Red Hat JBoss BPM Suite’s processes or tasks by using for example $scope.$apply in AngularJS. This will make tasks display their updated information with no need for the user to
explicitly request an update. This makes it convenient when working with multiple tasks simultaneously or while
infrequently receiving new tasks to an in queue.
Red Hat MAP together with Red Hat JBoss BPM Suite, leveraging the sync framework provide a simple way of building process driven, asynchronous mobile apps that can be used by mobile personnel.

Leave a Reply


Subscribe to our newsletter.

Please select all the ways you would like to hear from Open Sourcerers:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our newsletter platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.