Integrating IBM Worklight and IBM Business Process Manager Advanced using JMS, Part 1: Using a JMS adapter to integrate Worklight with a service integration bus

This series of articles demonstrates how IBM® Worklight® and IBM Business Process Manager can be combined using JMS technology to unleash the power of IBM’s middleware offerings through the mobile channel. This content is part of the IBM WebSphere Developer Technical Journal.

Raj Balasubramanian (raj_balasubramanian@us.ibm.com), Senior Technical Staff Member, IBM

Raj is a full time job as a dad, product designer & developer and a part time PhD student. He leads IBM Worklight Product Design for the US development teams. He works closely with customers to define the product requirements, and ensure that the technical architecture of the product release addresses these requirements. He focuses in the areas of cloud, security, mobile data management and analytics. His PhD thesis is focused on network analytic models and its application to social sciences.



Jeremy Nortey (janortey@us.ibm.com), Software Developer, IBM

Jeremy Nortey is a Software Developer for the IBM Mobile Foundation within Software Group. He develops software and quality assurance for mobile solutions. He specializes in iOS and dabbles in building native apps for the iPhone in his spare time. His hobbies include soccer and running.



Anand Chandramohan (anandcha@us.ibm.com), Managing Consultant, IBM

AnandNatraj Chandramohan (Anand), based out of Austin, TX, is a Technical Enablement Specialist providing deep technical expertise in the areas of SOA, SOMA & Process Integration. He has more than ten years of experience in the Business Integration field and provides end to end SOA solutions based on the WebSphere family of products to business partners and customers from various industries including Healthcare, Telecom and Insurance. His areas of expertise include BPM & ESB technologies, WebSphere Dynamic Process Edition and WebSphere Application Server. He is an Open Group Master Certified IT Specialist and he specializes in all aspects of BPM and SOA including development, deployment, performance and governance.



30 October 2013

Introduction

IBM Worklight is a mobile application platform that enables organizations to create mobile content for smartphones, tablets, and mobile web platforms. IBM Business Process Manager is a comprehensive business process management (BPM) platform for automating business processes and gaining visibility into those processes. Worklight has an adapter to support messaging through Java™ Messaging Service (JMS). This article examines how a mobile application running on a mobile device can trigger a long running business process in Business Process Manager. You will also see how the response from the business process can be delivered back to the mobile user using push notifications.

There are several patterns inherent in how various workflows and business processes are viewed, from control flow, data/resource, or exception handling perspectives. One of the common ways to classify actual resource usage on typical BPM systems is to use a time-based perspective: how long does the process state has to live. Hence, you have long-running processes that might last a few hours to possibly a several years (for example, a life insurance policy closeout) or short-running processes (or microflow) that might have to be completed in under a second or milliseconds (funds transfer). Because long-running processes are interruptible by nature and might demand an asynchronous interaction mechanism, the requirement of integration is much different than for the short running process.

Therefore, how the mobile devices and apps interact with the systems as they participate in the process can be categorized using styles that best suit the particular need. The diagram in Figure 1 illustrates the interaction between the mobile user using one or more devices to interact with the IBM Business Process Manager system. The blue arrow indicates inbound traffic while the black arrow indicates outbound traffic from Business Process Manager in the form of notifications.

Figure 1. Patterns for integrating Business Process Manager and Worklight
Patterns for integrating Business Process Manager and Worklight

Table 1 summarizes the interaction between mobile devices and the systems that participate in the process.

Table 1. Interaction patterns between Business Process Manager and Worklight
Interaction pattern (with flow type)Device <—> WorklightBusiness Process Manager <—> Worklight
Inbound: Invoking a long running processHTTP/S call from device to Worklight serverUse of JMS to initiate the process from Worklight to Business Process Manager
Outbound: Updating user of status of a long running processWorklight notifies device using an available push notification schemeBusiness Process Manager triggers a notification event to Worklight over HTTP
Inbound: Invoking a microflowHTTP/S call from device to Worklight serverHTTP/S call from device to Worklight server
Inbound: Invoking any process type requiring reliability of confirmed initiationHTTP/S call from device to Worklight serverUse of JMS to initiate the process from Worklight to Business Process Manager

The articles in this series will explore all of these interaction patterns and provide specific guideline and techniques (along with configuration) on implementing them. This article (Part 1) focuses on integrating Worklight with the Service Integration Bus (SIB) using the Worklight JMS adapter. Part 2 examines how a BPM long-running process picks up the message from a SIB request queue, triggers a BPM workflow, and returns a response back to an SIB response queue. The response message from SIB is correlated with the request message by the Worklight JMS adapter and is delivered back to the device using push notifications.

Prerequisites

To follow the steps in this article requires the following software (versions as noted or later):

  • IBM Worklight Studio Developer Edition V6.0
  • IBM Business Process Manager Advanced V8.0.1.1
  • IBM Integration Designer V8.0.1.1
  • IBM Websphere Application Server Liberty Profile extended runtime

Integration scenario

The sample presented here uses a simple “vacation requisition” use case to demonstrate the integration between Worklight and Business Process Manager. The flow of events shown in Figure 2 is described below.

Figure 2. End to end integration scenario
End to end integration scenario
  1. The mobile user submits the request using a Worklight application running on a mobile device.
  2. The Worklight JMS adapter forwards the message to the SIB request queue on the SIB running on Business Process Manager Advanced.
  3. This triggers a long running business process on Business Process Manager. The business process is completed by a human interaction (coach).
  4. Once complete, the Business Process Manager process replies by sending a message to the SIB response queue.
  5. The Worklight JMS adapter retrieves the response message and correlates it with the request message using JMSMessageID.
  6. The JMS adapter sends the response message to the push service mediator.
  7. The push service mediator sends a push notification to the device.
  8. The device processes the notification and displays an alert to the user informing him whether or not the vacation request has been approved.

Create JMS resources

In order to send and receive messages from SIB queues, you need to create these resources:

  • SIB: A service integration bus supports applications using message-based and service-oriented architectures. A bus is a group of one or more interconnected servers or server clusters that have been added as members of the bus. Applications connect to a bus at one of the messaging engines associated with its bus members.
  • SIB destinations: Destination where an application sends messages, or a source from which an application receives messages, or both. Queues and topic spaces are the two types of destinations within a bus. After you add a server as a member of the bus, choose queue for point-to-point messaging, or topic space for publish and subscribe messaging. A bus destination is a virtual place within a service integration bus, to which applications attach as producers, consumers, or both, to exchange messages.
  • JMS queues: After you define the type of destination for your messages in the service bus, you must associate those queues or topic spaces with JMS queues or topics. A JMS queue is used as a destination for point-to-point messaging. A JMS topic is used for JMS publish and subscribe messaging.
  • JMS queue connection factory: After you associate the bus queues or topic spaces to the JMS queues or topics, you must create a JMS connection factory. A JMS connection factory is used to create connections to the associated JMS provider of JMS queues for point-to-point messaging, or JMS topics for publish and subscribe messaging.

To create these JMS resources, you must first start the Business Process Manager Advanced server. On Windows®, you can start the server by issuing this command:

<BPM_INSTALL_ROOT>\profiles\ProcCtr01\bin\startServer.bat server1

Once the server is started, open a web browser and launch the WebSphere Integrated Solutions Console at http://<HOST_NAME>:<ADMIN_HOST>/ibm/console. For example:

http://localhost:9060/ibm/console

SIB

  1. Login to the admin console and navigate to Service integration > Buses and select New (Figure 3).
    Figure 3. Create new service integration bus
    Create new service integration bus
  2. Enter the name of your new bus as BPMWorklightBus. Deselect Bus security and click Next when done (Figure 4).
    Figure 4. Create a new bus
    Create a new bus
  3. Click Finish on the next panel. Save your changes to the master configuration.
  4. Select BPMWorklightBus and select Bus members (Figure 5).
    Figure 5. Bus members
    Bus members
  5. Click Add to add a bus member. Select the default standalone Server that is listed as a bus member, and then click Next (Figure 6).
    Figure 6. Choose bus member
    Choose bus member

    The members of a service integration bus can be application servers, server clusters, or IBM WebSphere MQ servers. Bus members that are application servers or server clusters contain messaging engines, which are the application server components that provide asynchronous messaging services. Bus members that are WebSphere MQ servers provide a direct client connection between a service integration bus and queues on a WebSphere MQ queue manager.

    When you add an application server or a server cluster as a bus member, a messaging engine for that bus member is created automatically. If the bus member is an application server, it can have only one messaging engine. To host queue-type destinations, the messaging engine includes a message store where, if necessary, it can hold messages until consuming applications are ready to receive them, or preserve messages in case the messaging engine fails. If the bus member is a WebSphere MQ server, it does not have a messaging engine, but it lets you access WebSphere MQ queues directly from WebSphere MQ queue managers and (for WebSphere MQ for z/OS®) queue-sharing groups.

  6. Choose File store as the type of message store and click Next (Figure 7).
    Figure 7. Choose bus member
    Choose bus member

    A message store enables a messaging engine to preserve operating information and to retain those objects that messaging engines need for recovery in the event of a failure. Each messaging engine has its own file store or data store. If the data store is chosen, the messaging engine uses an instance of a JDBC data source to interact with the database that contains the data store for that messaging engine. (See Resources)

  7. Keep the defaults for file store configuration and click Next.
  8. Keep the defaults for the performance parameters and click Next.
  9. Click Finish and then save changes to master configuration.
  10. At this stage, it’s a good idea to navigate to BPMWorklightBus > Messaging engines to ensure the messaging engine is started. (Make sure you can see a green arrow in the Status column, indicating that the messaging engine is started). If the messaging engine is not started, see these troubleshooting tips to resolve the start up issues.)
    Figure 8. Verify messaging engines
    Verify messaging engines

SIB destinations

  1. Navigate to Service integration > Buses and click on BPMWorklightBus (Figure 9).
    Figure 9. Select BPMWorklightBus
    Select BPMWorklightBus
  2. Select Destinations and then click on New to create a new destination (Figure 10).
    Figure 10. Create new destination
    Create new destination
  3. Create a new queue and enter BPMRequestQueue as the identifier. Select the default bus member in the next screen. In the last step, confirm queue creation and click Finish. Save the changes to the master configuration.
  4. Similarly, create one more queue named BPMResponseQueue. Remember to save changes to the master configuration when done. The panel should resemble Figure 11.
    Figure 11. SIB Destinations
    SIB Destinations

JMS queues

  1. From the Business Process Manager Advanced Integrated Solution Console, navigate to Resources > JMS > Queues. Select the server scope Node=win7-x64Node01, Server=server1, then click New (Figure 12).
    Figure 12. New JMS queue
    New JMS queue
  2. Select the default messaging provider as the JMS provider and click OK.
  3. Enter or select these values for the new JMS request queue (Figure 13):
    • Name: BPMRequestQueue
    • JNDI name: jndi/BPMRequestQueue
    • Bus name: BPMWorklightBus
    • Queue name: BPMRequestQueue
    Figure 13. JMS request queue properties
    JMS request queue properties
  4. Click OK when done. Save changes to the master configuration.
  5. Similarly, create a JMS response queue with these properties (Figure 14):
    • Name: BPMResponseQueue
    • JNDI name: jndi/BPMResponseQueue
    • Bus name: BPMWorklightBus
    • Queue name: BPMResponseQueue
    Figure 14. JMS response queue properties
    JMS response queue properties
  6. Click on OK when done. Save changes to the master configuration.

JMS queue connection factory

  1. Still in the Business Process Manager Advanced Integrated Solution Console, navigate to Resources > JMS > Queue connection factories. Select the server scope Node=win7-x64Node01, Server=server1 and click New (Figure 15).
    Figure 15. New queue connection factory
    New queue connection factory
  2. Select the default messaging provider as the JMS provider and click OK.
  3. Enter or select these values and click OK when done (Figures 16):
    • Name: BPMQCF
    • JNDI name: jndi/BPMQCF
    • Bus name: BPMWorklightBus
    Figure 16. Queue connection factory properties
    Queue connection factory properties
  4. Click OK when done. Remember to save changes to the master configuration.
  5. Restart the Business Process Manager Advanced server.

Create a Worklight application with a JMS adapter

Next, you will import a prebuilt sample Worklight application and create the JMS adapter in IBM Worklight Studio. To prepare for this:

Also,

  1. Download the following artifacts included with this article before proceeding:
    • VacationRequest.zip contains the prebuilt sample Worklight application that you will use to test the JMS integration.
    • SendMsg.zip contains the IBM Integration Designer mediation project used to send a message to the SIB queue
    • Customized server.xml for the Liberty extended runtime that contains JNDI mappings.
  2. Unzip the contents of VacationRequest.zip to C:\. Copy SendMsg.zip and server.xml to C:\
  3. Open Worklight Studio and import the Vacation Request application as shown in Figures 17 and 18.
    Figure 17. Import Worklight project
    Import Worklight project
    Figure 18. Import Worklight project
    Import Worklight project

Create Worklight application components: Client side entities

  1. In Worklight Studio, drill down to VacationRequest > apps > VacationRequest > common > VacationRequest.html. This is the main HTML file. Open the file and view the form that is used to submit a vacation request. Ensure you are in the Split tab display so that you can see both the HTML design and source (Figure 19).
    Figure 19. Vacation Request form
    Vacation Request form

    You will see that there are two functions:

    • sendVacationRequest() for submitting the request to the Business Process Manager server using the Worklight JMS adapter.
    • readResponse() for reading a response from the Business Process Manager server using the Worklight JMS adapter.
  2. Open VacationRequest > apps > VacationRequest > common > js > VacationRequest.js (Figure 20). This file is the main client side JavaScript™ file and contains the implementation logic to invoke the Worklight JMS adapter.
    Figure 20. VacationRequest.js
    VacationRequest.js
  3. Delete all existing contents in the file by pressing Ctrl-A and then the Delete key.
  4. Copy and paste the contents of Listing 1 into VacationRequest.js. Save and close the file when done.
    Listing 1. VacationRequest.js
    function wlCommonInit() {
    
    }
    
    function sendVacationRequest() {
    	var request = {
    		employeeName : $('#txtEmployeeName').val(),
    		employeeId : $('#txtEmployeeID').val(),
    		vacationDate : {
    			from : $('#txtVacationStart').val(),
    			to : $('#txtVacationEnd').val()
    		},
    		currentlyUtilized : false,
    		approved : false,
    		comments : ""
    	};
    
    	var requestString = JSON.stringify(request);
    	writeRequest(requestString);
    }
    
    /**********************************************************************************
     *                           Read Message
     **********************************************************************************/
    function readResponse() {
    
    	var invocationData = {
    		adapter : 'RequestAdapter',
    		procedure : 'readMessage',
    		parameters : []
    	};
    
    	WL.Client.invokeProcedure(invocationData, {
    		onSuccess : readResponseSuccess,
    		onFailure : function(response) {
    			WL.Logger.debug("Read Failed");
    			WL.SimpleDialog.show("Read Response Status",
    					"Read Response Failure", [ {
    						text : "Press Ok to Continue"
    					} ]);
    		}
    	});
    }
    
    function readResponseSuccess(response) {
    	WL.Logger.debug("Read Success");
    
    	WL.Logger.debug(response.invocationResult);
    
    	var requestResponse = response.invocationResult.body;
    	WL.Logger.debug(requestResponse);
    	
    	var response = extractInputXMLNodeData(requestResponse);
    	WL.Logger.debug(response);
    	
    	WL.SimpleDialog.show("Read Response Status", response, [ {
    		text : "Press Ok to Continue"
    	} ]);
    
    }
    
    /**********************************************************************************
     *                           Write Message
     **********************************************************************************/
    function writeRequest(message) {
    
    	var invocationData = {
    		adapter : 'RequestAdapter',
    		procedure : 'writeMessage',
    		parameters : [ message ]
    	};
    
    	WL.Client.invokeProcedure(invocationData, {
    		onSuccess : function(response) {
    			WL.Logger.debug("Write Successful");
    			WL.SimpleDialog.show("Submit Request Status",  
    "Submit Request Successful", [ {
    				text : "Press Ok to Continue"
    			} ]);
    		},
    		onFailure : function(response) {
    			WL.Logger.debug("Write Failed");
    			WL.SimpleDialog.show("Submit Request Status", 
    "Submit Request Unsuccessful", [ {
    				text : "Press Ok to Continue"
    			} ]);
    
    		}
    	});
    }
    
    /**********************************************************************************
     *                           Utility function
     **********************************************************************************/
    function extractInputXMLNodeData (xmlString) {
    	if (xmlString) {
    		var inputXMLRe  = /\<input\>[a-zA-Z0-9]+\<\/input\>/;
    		var inputStartRe = /\<input\>/;
    		var inputEndRe = /\<\/input\>/;
    
    		var inputXML = xmlString.match(inputXMLRe);
    		if (inputXML) {
    			var inputXMLString = inputXML[0];
    			inputXMLString = inputXMLString.replace(inputStartRe, "")
    .replace(inputEndRe, "");	
    			return inputXMLString;
    		}
    	}
    	return "";
    }

    Description of functions inside VacationRequest.js:

    • sendVacationRequest: Constructs the request object to be sent to the Worklight JMS adapter from the DOM (Document Object Manager) using jQuery and invokes the writeRequest () function with the request data.
    • readResponse: Invokes the Worklight JMS adapter to read the response message from the Business Process Manager server.
    • readResponseSuccess: Success callback method for the readResponse() function. It parses the JSON response and displays a simple dialog (Worklight common control) to display the approval status.
    • writeRequest: Invokes the Worklight JMS adapter to send data to the Business Process Manager server.
  5. Now you will create a Worklight environment for the Android platform. Worklight applications run in mobile, tablet, and web environments. Run time environments differ in many aspects, such as screen size, orientation, specific UI guidelines and components, physical user interface, and unique environment functionality. Worklight increases development efficiency and productivity by providing an environment optimization framework. The core logic and design guidelines of the app are written by using web technologies (HTML, CSS, JavaScript) and are shared by all environments.

    Right click on VacationRequest > apps > VacationRequest and select New > Worklight Environment (Figure 21).

    Figure 21. Add New Worklight Environment
    Add New Worklight Environment
  6. Select Android phones and tablets and click Finish. Wait until the build process for the new environment is complete. This could take a few minutes (Figure 22).
    Figure 22. Select Android phones and tablets
    Select Android phones and tablets

Create the Worklight JMS adapter: Server side entity

An adapter is a transport layer that is used by the Worklight platform to connect to various back end systems. Adapters that are included with the product include an SQL adapter, HTTP adapter, Cast Iron® adapter, and JMS adapter. Adapters use simple XML syntax and are easily configured with JavaScript API. Data that is retrieved by an adapter can be returned raw or preprocessed by the adapter itself. In both cases, it is presented to the application as a JSON object.

You will now create the Worklight JMS adapter to send and receive JMS messages from the SIB queues on the Business Process Manager server.

  1. Right click on VacationRequest > adapters and select New > Worklight Adapter (Figure 23).
    Figure 23. Create new Worklight adapter
    Create new Worklight adapter
  2. Specify the Adapter type as JMS adapter and Adapter name as RequestAdapter (Figure 24). Click when done.
    Figure 24. Specify adapter properties
    Specify adapter properties
  3. RequestAdapter.xml will open by default. Drill down to Adapter “RequestAdapter” > Connectivity > connectionPolicy. In the right panel under jmsConnection, enter these values:
    • connectionFactory: jndi/MyQCF
      This must be the same string as the one defined for the JMSQueueConnectionFactory in the server.xml.
    • password: admin
      This can be any string value.
    • user: admin
      This can be any string value.
    Figure 25. Adapter Editor
    Adapter Editor
  4. Save and close the RequestAdapter.xml file.
  5. Open RequestAdapter-impl.js (Figure 26). This file will contain the implementation for the functions defined in RequestAdapter.xml.
    Figure 26. RequestAdapter-impl.js
    RequestAdapter-impl.js
  6. Delete all existing contents in the file by pressing Ctrl-A and then the Delete key.
  7. Copy and paste the contents of Listing 2 into RequestAdapter-impl.js. Save and close the file when done.
    Listing 2. RequestAdapter-impl.js
    /**
     * @param message
     * 
     * @returns the result which includes the MessageID if successful
     */
    function writeMessage(message) {
    
    	var result = WL.Server.writeJMSMessage({
    		destination : "jndi/BPMRequestQueue",
    		message : {
    			body : message,
    			properties : {
    				MY_USER_PROPERTY : 123456
    			}
    		}
    	});
    
    	if (!result.JMSMessageID) {
    		WL.Logger.debug(">> JMS adapter >> writeMessage >> message not sent");
    		return {};
    	} else {
    		WL.Logger.debug(">> JMS adapter >> writeMessage >> message sent ::");
    		WL.Logger.debug("result:messageID: " + result.JMSMessageID);
    		return result;
    	}
    }
    
    /**
     * 
     * 
     * @returns the message, if successful
     */
    function readMessage() {
    
    	var result = WL.Server.readSingleJMSMessage({
    		destination : "jndi/BPMResponseQueue",
    		timeout : 60
    	});
    
    	if (!result.message) {
    		WL.Logger
    				.debug(">> JMS adapter >> readNextMessage >> no messages in queue");
    		return {};
    	} else {
    		WL.Logger
    				.debug(">> JMS adapter >> readNextMessage >> message received ::");
    		return result.message;
    	}
    	;
    }

    Description of functions inside VacationRequest.js:

    • writeMessage: Sends a message to the SIB JMS queue, namely the BPMRequestQueue, which is on the Business Process Manager server.
    • readMessage: Reads a response from the SIB JMS queue, namely the BPMResponseQueue, which is on the Business Process Manager server.

Using Worklight with Liberty and the extended JMS features

The Worklight server can be run on various supported application servers including WebSphere Application Server, WebSphere Application Liberty profile, and Tomcat. For the purpose of this article, we will be leveraging Liberty and its new set of extended features that come with JMS support.

The Liberty extended features (Figure 27) in WebSphere Application Server V8.5.5 include components that enable Liberty to act as both a JMS client and a JMS server. In order to connect from Liberty to a Business Process Manager SIB through JMS, it will be necessary to extend your Liberty server with these features.

Figure 27. Liberty profile extended features
Liberty profile extended features

You can download the Liberty profile and its extended features from the WASdev community.

Install Liberty V8.5.5 extended features:

  1. Locate the file wlp-extended-8.5.5.0.jar in your command line.
  2. Enter the following in your command line: java -jar wlp-extended-8.5.5.0.jar.
  3. Follow the instructions regarding the licensing terms and continue.
  4. You will then be asked to enter the location of the Liberty server that you wish to have extended. Enter the location that contains the “wlp” folder of your Liberty server. We’ll assume the Liberty server was installed under C:\Liberty\wlp.
  5. The extended features will be installed and the jar file will also run tests to verify that they were installed properly.
  6. Navigate to C:\Liberty\wlp\bin and create a Liberty extended profile using the command:

    server.bat create worklightExtended

  7. Ensure you see this success message:

    Server worklightExtended created.


JNDI mappings between Worklight, Liberty, and SIB

Worklight does not make a direct connection to the Business Process Manager SIBus. The Worklight JMS adapter will make a JNDI call to a connection factory and a queue that is configured on the Liberty server. The Liberty server will contain a mapping to the SIBUS connection factory and queue (Figure 28).

Figure 28. JMS mapping
JMS mapping

A customized server.xml file with the above JNDI mappings has been provided in the sample download artifacts. Copy and paste this custom server.xml file into the directory C:\Liberty\wlp\usr\servers\worklightExtended.

Be aware that you will need to overwrite the existing server.xml file with this custom file.


Import the Liberty Server runtime into the workspace

You now need to import the Liberty Extended Server runtime into the Worklight Studio workspace and set it as the target server for the VacationRequest application.

  1. Right click on VacationRequest and select Change Worklight Target Server (Figure 29).
    Figure 29. Change Worklight Target Server
    Change Worklight Target Server
  2. Click on Add Server (Figure 30).
    Figure 30. Add Server
    Add Server
  3. Click Add (Figure 31).
    Figure 31. Define a New Server
    Define a New Server
  4. Specify C:\Liberty\wlp for the Path and click Finish (Figure 32).
    Figure 32. Select Server Path
    Select Server Path
  5. Click Next (Figure 33).
    Figure 33. Define a New Server
    Define a New Server
  6. Click Finish (Figure 34).
    Figure 34. Liberty Profile Server
    Liberty Profile Server
  7. Change the Worklight Target Server to WebSphere Application Sever V8.5 Liberty Profile at localhost. Click Save (Figure 35).
    Figure 35. Worklight Target Server
    Worklight Target Server
  8. Navigate to WebSphere Application Sever V8.5 Liberty Profile >servers > worklightExtended > server.xml (Figure 36). Open the file and ensure you are in the Source view.
    Figure 36. server.xml
    server.xml
  9. Review the contents of the file very closely (Figure 37), as it contains the connection details to the SIB JMS queues on the Business Process Manager server, and the definitions of the SIB JMS queues. If the connection details to your Business Process Manager server are different, you can modify the settings here. Remember to save the file if you made changes.
    Figure 37. server.xml properties
    server.xml properties

Deploy the Worklight application and adapter

  1. Right click on VacationRequest > apps > VacationRequest and select Run As > Build All and Deploy (Figure 38).
    Figure 38. Build and deploy project
    Build and deploy project
  2. The build and deploy step will take a few minutes depending upon your machine configuration. Observe the console logs to ensure that the application was deployed successfully (Figure 39).
    Figure 39. Verify server console logs
    Verify server console logs
  3. Similarly deploy the RequestAdapter project (Figure 40).
    Figure 40. Deploy project
    Deploy project
  4. Again, observe the console logs to ensure that the RequestAdapter was deployed successfully (Figure 41).
    Figure 41. Verify server console logs
    Verify server console logs

Request test: Sending a message from the Worklight application

  1. Launch a browser and point to the URL http://localhost:10080/VacationRequest/console/. The mobile browser simulator in Worklight supports these web browsers:
    • Firefox version 3.6 and later.
    • Chrome 17 and later.
    • Safari 5 and later.
  2. Click on the eye shaped icon next to the Android environment icon (Figure 42).
    Figure 42. IBM Worklight Console
    IBM Worklight Console
  3. This will launch the mobile browser simulator, which you can use to test the Worklight application. Complete the vacation requisition form with data and click on the Submit Request button (Figure 43).
    Figure 43. Mobile browser simulator
    Mobile browser simulator
  4. You will be prompted with a Worklight simple dialog that displays the status of the Submit Request operation (Figure 44). Click OK to dismiss the dialog.
    Figure 44. Submit Request Status
    Submit Request Status
  5. Launch the WebSphere Integrated Solutions Console for your Business Process Manager Advanced server, which is typically available at http://localhost:9060/ibm/console. Login by typing the username and password.
  6. Navigate to Service integrations > Service Integration Bus Browser (Figure 45).
    Figure 45. Service Integration Bus Browser
    Service Integration Bus Browser
  7. On the right side, drill down to Queue Points on the BPMWorklightBus. You will observe a message count of 1 on the BPMRequestQueue. Click on the Queue depth count (in this case “1”). Click Continue if you get a security warning (Figure 46).
    Figure 46. Queue Points
    Queue Points
  8. Click on the Identifier value (Figure 47).
    Figure 47. Identifier
    Identifier
  9. Click on Message Body (Figure 48).
    Figure 48. Message Body
    Message Body
  10. You can view the message that was sent by the Worklight application using the JMS adapter (Figure 49).
    Figure 49. Message content
    Message Body
    (Part 2 will demonstrate how this message can be processed by a long running business process.)

Response test: Receiving a message from an SIB JMS queue

You will now use a simple mediation module inside IBM Integration Designer to send a response message back to the SIB JMS queue. From there, the Worklight JMS adapter will receive the message and deliver it to the VacationRequest application.

  1. Launch IBM Integration Designer and select a workspace.
  2. Import the SendMsg.zip project interchange file (Figure 50). Wait for a few minutes until the build process completes.
    Figure 50. Import Project Interchange
    Import Project Interchange
  3. Open the Assembly diagram and review the mediation flow. In particular, pay attention to the JMS Import. Notice that the Default message type for the JMS binding has been set to “Text” (Figure 51).
    Figure 51. JMS Import properties
    JMS Import properties
  4. Review the End-Point Configuration to ensure that the JMS connection factory and destination have been set correctly (Figure 52 and 53).
    Figure 52. End-Point Configuration
    End-Point Configuration
    Figure 53. JMS Import properties
    End-Point Configuration
  5. If you made any changes, save your flow and re-build the project.
  6. Deploy the SendMessage module to the BPM server (Figure 54). This should be same server in which you created the JMS resources.
    Figure 54. Deploy project
    Deploy project
  7. Make sure that SendMessage has been deployed successfully and is in a started state (Figure 55).
    Figure 55. Verify application start
    Verify application start
  8. Switch back the Assembly diagram. Right click on SendMessageMediation and select Test Component (Figure 56).
    Figure 56. Test component
    Test component
  9. Enter Approve as the value in the Value editor and click on Run (Figure 57).
    Figure 57. Run test
    Run test
  10. Be sure that the test completes successfully (Figure 58).
    Figure 58. Verify test completion
    Verify test completion
  11. Switch back to the WebSphere Integrated Solutions Console for the Business Process Manage Advanced server and drill down to the queue points of the BPMWorklightBus (Figure 59). You can observe that the queue depth for the BPMResponse queue is now 1.
    Figure 59. Queue Points
    Queue Points
  12. Bring the mobile browser simulator for VacationRequest application back to forefront and click on Read Message (Figure 60).
    Figure 60. Mobile browser simulator
    Mobile browser simulator
  13. You will be prompted with a Worklight simple dialog that displays the approval status of the vacation request. This is the same value you entered in the Integration Test Client in IBM Integration Designer.
    Figure 61. Simple dialog
    Simple dialog
  14. Click Press Ok to continue to dismiss the dialog.

Conclusion

The first part of this article series demonstrated how to integrate IBM Worklight V6.0 with a service integration bus (SIB) using the Worklight JMS adapter. In the next article, you will see how a long running BPM process will pick up the message from a SIB request queue, trigger a BPM workflow, and return a response back to an SIB response queue. You will also see how the response message from SIB will be correlated with the request message by the Worklight JMS adapter and be delivered back to a device using push notifications.


Acknowledgement

The authors thank Ed Grossman, Executive IT Specialist with IBM WW WebSphere Business Partners, and David Dhuyvetter, a software engineer with IBM Software Services for WebSphere, for providing a valuable technical review of this article.


Download

DescriptionNameSize
Sample codedownloads.zip333 KB

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere, Mobile development
ArticleID=950461
ArticleTitle=Integrating IBM Worklight and IBM Business Process Manager Advanced using JMS, Part 1: Using a JMS adapter to integrate Worklight with a service integration bus
publish-date=10302013