Page History
Table of Contents |
---|
Introduction
This article describes how to implement a JS7 Workflow workflow with two shell jobs that communicate over a Message Queue Service (MQ). These jobs include a one job for publishing and one job for receiving and executing JS7 JOC - REST Web Service API calls.
The document explains which classes and methods have to be created and their respective purposes. This example was has been developed with the use of Apache MQ.
...
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 JOC REST Web Service API nor the complete possibilities of JMS.
For the coverage of the JS7 JOC REST Web Service API refer to JOC API Documentation the Technical Documentation of the REST Web Service API article.
For the coverage of the JMS API refer to the Oracle Java JMS Documentation.
...
Use Case
The use case consists of includes the following steps:
- Run Running a shell Job that runs job which executes a Java class on an Agent which . This sends a JSON body to a message queue Message Queue (MQ) Run
- Running a shell Job that runs job which executes a Java class on an Agent which . This receives a JSON body from an MQ a Message Queue and executes a JOC JS7 REST Web Service API call with the given JSON body.
What
...
the example
...
explains
This article shows the workflow configuration with the example implementation explained here.
Download
The library with the classes described in this example can be downloaded here.
The workflow configuration can be downloaded here.
Prerequisites
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 For this example 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 classpathclass path
- or, in the case of a Maven project, add the following dependency to the project configuration.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.15.0</version> </dependency> |
The Workflow
- Adjust the
js7-jms-example.config
configuration file to your own environment.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# Message Queue Service Settings
jms_url = tcp://localhost:61616
jms_queue_name = test
jms_time_to_live = 5000
# JS7 JOC Cockpit Settings
joc_api_url = http://localhost:4444/joc/api/
username = root
password = root
# /orders/add API Settings
controller_id = js7
workflow_path = /myWorkflowToStart |
Workflow
The workflow in this example includes two jobs The example Workflow has two Jobs which both call the main class of the JmsExample.java
class with either a "produce
" or a "consume
" argument.
- the argument "produce" determines to use
produce
argument specifies the use of a SOSProducer to publish a message (JSON body) to a message queueMessage Queue Service. - the argument "consume" determines to use
consume
argument specifies the use of a SOSConsumer to read a message (JSON body) from a message queue andMessage Queue Service andto:- 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 on the path included in the PATH
environment variable or the java Java call has to be adjusted with to include the path to your java executablethe Java executable.
Note |
---|
Make sure that the 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. |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
{ "version": "1.1.0", "timeZone": "Europe/Berlin", "instructions": [ { "TYPE": "Execute.Named", "jobName": "producer_job", "label": "job_produce" }, { "TYPE": "Execute.Named", "jobName": "consumer_job", "label": "job_consume" } ], "jobs": { "producer_job": { "agentName": "standaloneAgent", "executable": { "TYPE": "ShellScriptExecutable", "script": "java -jar C:/sptmp/devel/js7/JMS/-jms-example-js7.jar produce", "v1Compatible": false }, "skipIfNoAdmissionForOrderDay": false, "parallelism": 1, "graceTimeout": 15, "failOnErrWritten": false, "warnOnErrWritten": false, "title": "produce" }, "consumer_job": { "agentName": "standaloneAgent", "executable": { "TYPE": "ShellScriptExecutable", "script": "java -jar C:/sptmp/devel/js7/JMS/-jms-example-js7.jar consume", "v1Compatible": false }, "skipIfNoAdmissionForOrderDay": false, "parallelism": 1, "graceTimeout": 15, "failOnErrWritten": false, "warnOnErrWritten": false, "title": "consumer" } } } |
...