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 (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 purposes. This example was is 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 a shell Job job that runs executes a Java class on an Agent which sends a JSON body to a message queue Message Queue (MQ)
- Run a shell Job job that runs executes a Java class on an Agent which 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 heresample implementation explained with the JS7 - Example - How to send and receive messages with a JMS Message Queue article.
Download
The Download the library used in this example can be downloaded here: jms-example-js7.jar.The workflow configuration can be downloaded here
Download the workflow configuration (upload .json): jms_example_workflow.zip.
Prerequisites
For this example the activemq-all-5.15.0.jar
library is used.
- Either download the .jar file from the Active MQ and add it to the classpathclass path
- or in 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> |
...
Workflow
The workflow in this example Workflow has includes two Jobs jobs which both call the main class of the JmsExample.java
class with either a "produce
" or a "consume
" argument.
- the
produce
argument "produce" determines to use of a SOSProducer to publish a message (JSON body) to a message queueMessage Queue. - the
consume
argument "consume" determines to use of a SOSConsumer to read a message (JSON body) from a message queue Message Queue andto login to a JS JOC the JS7 REST Web Service API, to send an the API call/orders/add
with the body received from the message queue Message Queue and finally to logout again.
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 the path to your java the Java executable.
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:/sp/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:/sp/devel/js7/JMS/jms-example-js7.jar consume", "v1Compatible": false }, "skipIfNoAdmissionForOrderDay": false, "parallelism": 1, "graceTimeout": 15, "failOnErrWritten": false, "warnOnErrWritten": false, "title": "consumer" } } } |
...