Versions Compared

Key

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

...

This can be achieved by using the return value spooler_job.order_queue() != null. It determines if an order is in the queue of the job (true) or not (false).

Logging

Because the Java Jobs run API methods, we can directly use the logging feature of the JobScheduler. As shown in the detailed method examples below, logging is done by using the spooler_log method.

Make sure to throw the catched exception in order to hand it over the spooler_process() method. This is needed for a job running in a job chain to determine that it has to fail in case an error occurs.

Initialization of the MQ Connection

...

Code Block
languagejava
titlecreateConnection(String urluri)
linenumberstrue
collapsetrue
public Connection createConnection(String uri){
    factory = new ActiveMQConnectionFactory(uri);
    Connection jmsConnection = null;
        try {
            jmsConnection = factory.createConnection();
        } catch (JMSException e) {
            spooler_log.error("JMSException occurred while trying to connect: ");
            throw e;
        }
        return jmsConnection;
}

The createSession(Connection connection) method

The method is called with an already instantiated Connection object and instantiates a Session object through the Connection object´s createSession(boolean transacted, int acknowledgeMode) method.

The acknowledgeMode has the following options among others:

In summary the acknowledge mode AUTO_ACKNOWLEDGE results in the message be dequeued when one consumer has read the message from the MQ server, whereas the CLIENT_ACKNOWLEDGE puts the responsibility on the client.

When the acknowledge mode CLIENT_ACKNOWLEDGE is set, the message will stay present for all consumers to read until a consumer acknowledges the message. Only then the message will be dequeued and is not available for further consumers.

 

Code Block
languagejava
titlecreateSession(Connection connection)
linenumberstrue
collapsetrue
private Session createSession(Connection connection) throws JMSException{
    Session session = null;
    try {
        session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    } catch (JMSException e) {
        spooler_log.error("JMSException occurred while trying to create Session: ");
        throw e;
    }
    return session;
}

 

 

Implementation of the Producer Job

...