Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 This method is called with an already active Session object as well as an instantiated Destination object. It instantiates a MessageProducer object MessageProducer object with the given session and destination.

...

The method is called with the message to be sent to the server, the connection URL to the server and the queue name to use be used for publishing. The message is a String object. The method instantiates a Message object with the text to send. This method makes use of the methods described above. It instantiates all objects needed for the connection and sends a Message object. Also the methods throws an error if one occurs. Although this method may throw an error, it still calls the MessageProducer´s send(Message message)  method in a try..catch..finally block. That is because the use of the  finally block is used to close the connection in the end.

...

This is the core method of the Producer Java job. It reads the parameters from the task and order, does some logging at debug level, calls the createConnectionUrl(..) method  and subsequently calls the write(..) method to send the message to the MQ server.

...

The method is called with an already instantiated Connection object, the name of the queue to read from and a flag to determine if this is the last consumer. If it is the last consumer for the messages in the specified queue then the reiceived received message will be acknowledged. This method makes use of the methods described above. It instantiates all objects needed for the connection and reads a Message object from the given queue. It extracts the value from the Message object as a string representation via the Message object´s getText() method. We have to make sure that connection.start() is called before the MessageConsumer object is instantiated.

...

This method calls the executeXml(String message) method mentioned above for each given target job chain. It replaces the jobChain job_chain argument of the (XML) message with the given job chain names form from the job parameter.

Code Block
languagejava
titleexecuteXmlForAllTargets(String message)
linenumberstrue
collapsetrue
private void executeXmlForAllTargets(String message) {
    if (targetJobChains.contains(DELIMITER) && message.contains("add_order")) {
        String [] jobChainNames = targetJobChains.split("[" + DELIMITER + "]");
        for (String name : jobChainNames){
            spooler_log.debug9("add_order XML will be adjusted for JobChain: " + name);
            executeXml(message.replaceFirst("job_chain='[^']*'", "job_chain='" + name + "'"));
        }            
    }else{
        executeXml(message);
    }
}

...

This is the core method of the Producer Java job. It reads the parameters from the task and order, does some logging at debug level, calls the createConnectionUrl(..) method and subsequently calls the read(..) method. The received message as well as the name(s) of the target job chain(s) are store stored globally in the class for further processing.

...

The last thing to do is for the Consumer Job is to call the execute() method as well as the executeXmlForAllTargets(String message) method in spooler_process() , as shown in the complete code example below.

...

To be able to run the new Java jobs simply deploy(/copy ) the created jar library to the user_lib folder in your $SCHEDULER_HOME.

...

Create a new Job and write the class name including the package structure in the Classname field Classname. Because of the use case of the example let´s . Let´s call the job XML_Producer after the example's use case. 

Configure the parameters for the job as shown below.

...

Create a new Job and write the class name including the package structure in the field Classname. Because of the use case of the example let´s field. Let´s call the job job XML_Consumer after the example's use case. 

 

Configure the parameters for the job as shown below.

The targetJobChainName parameter targetJobChainName is only needed if you want to change the configuration as shown in the message parameter of the producer job.

 

Create the

...

Job Chain with JOE

This jobchain configuration is only job chain configuration has been written to show the processing of the job , - therefore both jobs are put in the same jobchainjob chain. In a production environment it is more likely that both jobs would reside in different jobchainsjob chains, that there are is more than one consumersconsumer, etc...

Create a Jobchain job chain which looks like the example below. 

...