JMS WebSphere MQ outgoing connections

Overview

Asynchronously sends a message to a WebSphere MQ queue manager using connection parameters specified.

The application on the receiving end is assumed to have been written in Java using MQ JMS API. This allows for seamless integration with Java JMS WMQ systems - from their point of view Zato, despite being written in Python, will appear to be a Java application.

The message is first published on the Zato broker off of which the connector process responsible for communication with this particular queue manager picks it up and actually sends it to the remote queue.

The underlying client JMS WMQ libraries are PyMQI and Spring Python.

Note

Before making using of the connections, PyMQI needs to be first manually enabled by administrators.

API

self.outgoing.jms_wmq.send

send(msg, out_name, queue, delivery_mode=None, expiration=None, priority=None, max_chars_printed=None):

Uses an outgoing connection of a given name to send a JMS message to a WebSphere MQ queue manager.

Optional parameters, if not given, take values from the connection template, which in turn uses default values Spring Python provides and these are in accordance with the JMS spec.

Parameters:
  • msg (string) – Message to send
  • out_name (string) – Outgoing connection to use
  • queue (string) – Name of the queue to put a message on
  • delivery_mode (DELIVERY_MODE_NON_PERSISTENT or DELIVERY_MODE_PERSISTENT from the springpython.jms module) – Whether the message should be persistent or not
  • expiration (int) – After how many milliseconds after reaching the queue should the message expire
  • priority (int) – Message priority between 1 and 9 - 1 being the minimum priority
  • max_chars_printed (int) – How many characters of the message should Spring Python write out to logs when running in DEBUG mode
Return type:

(None)

Usage example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from zato.server.service import Service

class MyService(Service):
    def handle(self):

        # Request parameters
        msg = 'Hello MQ!'
        out_name = 'Customer Cases'
        queue = 'CUSTOMER.CASES.1'

        # Send the message to a queue manager
        self.outgoing.jms_wmq.send(msg, out_name, queue)

When caught travelling over the wire the raw bytes sent across to the queue manager can be confirmed to be a JMS message indeed.

RFH \x00\x00\x00\x02\x00\x00\x00\xa0\x00\x00\x01\x11\x00\x00\x04\xb8
MQSTR   \x00\x00\x00\x00\x00\x00\x04\xb8\x00\x00\x00x
<jms><Dst>queue:///CUSTOMER.CASES.1</Dst><Tms>1367515530623</Tms><Dlv>1</Dlv>
<Exp>1367515535623</Exp><Pri>5</Pri></jms> Hello MQ!