Introduction
This article describes how to implement a JS7 workflow with two shell jobs that communicate over a Message Queue Service (MQ). These jobs include one job for publishing and one job for receiving and executing JS7 - REST Web Service API calls.
The document explains which classes and methods have to be created and their respective purposes. This example has been developed for use with https://activemq.apache.org/.
Purpose of the Example
The example covers the specifics required to achieve the use case described below. It neither covers the complete JS7 REST Web Service API nor the complete possibilities of JMS.
For coverage of the JS7 REST Web Service API refer to the Technical Documentation of the REST Web Service API article.
For coverage of the JMS API refer to the Oracle JMS Documentation.
Use Case
The use case includes the following steps:
- Running a shell job which executes a Java class on an Agent. This sends a JSON body to a Message Queue (MQ)
- Running a shell job which executes a Java class on an Agent. This receives a JSON body from a Message Queue and executes a JS7 REST Web Service API call with the given JSON body.
What the example explains
This article shows the workflow configuration with the sample implementation as explained in the JS7 - Example - How to send and receive messages with a JMS Message Queue Service article.
Download
Download the library used in this example: js7-jms-example-jar.zip.
The archive contains:
- the
js7-jms-example.jar
used in this example, - the
js7-jms-example.config
configuration file containing credentials for the connection and information about the workflow.
Download the workflow configuration (upload .json): js7-jms-example-workflow.zip.
Prerequisites
The activemq-all-5.15.0.jar
library is used for this example.
- Either download the .jar file from the Active MQ web site and add it to the class path
- or, in the case of a Maven project, add the following dependency to the project configuration.
- Adjust the
js7-jms-example.config
configuration file to your own environment.
Workflow
The workflow in this example includes two jobs which both call the main class of the JmsExample.java
class with either a produce
or a consume
argument.
- the
produce
argument specifies the use of a SOSProducer to publish a message (JSON body) to a Message Queue Service. - the
consume
argument specifies the use of a SOSConsumer to read a message (JSON body) from a Message Queue Service and to:- login to the JS7 REST Web Service API,
- send the API call
/orders/add
with the body received from the Message Queue Service and finally to - logout.
The Java executable has to be included in the PATH
environment variable or the Java call has to be adjusted to include the path to the Java executable.
js7-jms-example.config
configuration file from the archive is stored in the same path as the js7-jms-example.jar
library used in the workflow.