You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Introduction

This article describes how to implement a JS7 workflow with two shell jobs that communicate over a Message Queue (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 purposes. This example is 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:

  1. Run a shell job that executes a Java class on an Agent which sends a JSON body to a Message Queue (MQ) 
  2. Run a shell job that executes a Java class on an Agent which 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 explained with the JS7 - Example - How to send and receive messages with a JMS Message Queue Service article.

Download

Download the library used in this example: jms-example-js7.jar.

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 class path
  • or in case of a Maven project add the following dependency to the project configuration.

Maven dependency for activemq-all
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.15.0</version>
</dependency>

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 determines use of a SOSProducer to publish a message (JSON body) to a Message Queue Service.
  • the consume argument determines 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, to send the API call /orders/add with the body received from the Message Queue and finally to logout.

The Java executable has to be included in the PATH environment variable or the Java call has to be adjusted with the path to the Java executable.

jms_test
{
  "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"
    }
  }
}



  • No labels