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

Compare with Current View Page History

« Previous Version 6 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 a job for publishing and one for receiving and executing JS7 JOC API calls.

The document explains which classes and methods have to be created and their purposes. This example was developed with the use of Apache MQ.

Goal of the Example

The example covers the specifics required to achieve the use case described below. It neither covers the complete JS7 JOC API nor the complete possibilities of JMS.

For the coverage of the JS7 JOC API refer to JOC API Documentation.

For the coverage of the JMS API refer to the Oracle Java Documentation.

The Use Case

The use case consists of the following steps:

  1. Run a shell Job that runs a Java class on an Agent which sends a JSON body to a message queue (MQ) 
  2. Run a shell Job that runs a Java class on an Agent which receives a JSON body from an MQ and
  3. executes a JOC API call with the given JSON body.

What does this example explain?

This article shows the workflow configuration with the example implementation explained here.

Download

The library used in this example can be downloaded here.

The workflow configuration can be downloaded here.

Prerequisites

For this example the activemq-all-5.15.0.jar library is used.

  • Either download the jar file and add it to the classpath
  • 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>

The Workflow

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 a SOSProducer to publish a message (JSON body) to a message queue.
  • the argument "consume" determines to use a SOSConsumer to read a message (JSON body) from a message queue and
  • login to a JS JOC API, send an API call /orders/add with the body received from the message queue and logout again.

Java has to be on the path or the java call has to be adjusted with the path to your 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