Table of Contents
Just a second...

Configuring the JMS Adapter v5.1

The configuration file for the legacy Java Message Service (JMS) adapter v5.1 is typically called JMSAdapter51.xml, although you can override this by using a setting in Publishers.xml.

  1. Configure Publishers.xml

    Instantiate the JMS adapter by enabling it in etc/Publishers.xml, for example:

    <publisher name="JMSAdapter">
      <class>com.pushtechnology.diffusion.adapters.jms51.JMSAdapter</class>
      <enabled>true</enabled>
      <start>true</start>
      <property name="config.filename">../adapters/JMSAdapter51.xml</property>
    </publisher>
  2. Configure JMSAdapter51.xml

    A JMSAdapter51.xml for ActiveMQ can look like this:

    <property name="use.global.session">false</property>

    Similarly, a sample JMSAdapter51.xml TIBCO Enterprise Message Service™ looks like this:

    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <jms-config>
      <binding>
        <env>
          <property name="java.naming.factory.initial">
            com.tibco.tibjms.naming.TibjmsInitialContextFactory
          </property>
          <property name="java.naming.provider.url">
            tcp://localhost:7222
          </property>
          <property name="java.naming.security.principal">
    	jndi_username
          </property>
          <property name="java.naming.security.credentials">
    	jndi_password
          </property>
        </env>
        <connection-factory name="ConnectionFactory">
          <credentials username="jms_username" password="jms_password"/>
          <reconnect>
    	<max-reconnections>10</max-reconnections>
    	<interval>5000</interval>
          </reconnect>
        </connection-factory>
        <root-topic>jms/tibco</root-topic>
        <priority low="3" high="7" />
        <queue-distribution-mode>SMALLEST_QUEUE</queue-distribution-mode>
      </binding>
      <mapping>
        <artefact-names jms=".$" diffusion="/~"/>
      </mapping>
    </jms-config>

    TIBCO Enterprise Message Service requires that a ConnectionFactory definition is provided in factories.conf, for example:

    [ConnectionFactory]
      type = generic
      url = tcp://localhost:7222
      ssl_verify_host = disable

    This has been tested with TIBCO Enterprise Message Service 7.0; see the TIBCO Enterprise Message Service documentation for further details.

    For IBM MQ v7.x, the binding section can look like this:

    <env>
      <property name="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</property>
      <property name="java.naming.provider.url">file:///var/mqm/jndi</property>
    </env>

    IBM MQ can include MQRFH2 headers in messages sent between JMS and non-JMS systems. For control over this behavior, set the property in mq.target.client in Publishers.xml; to disable the headers, set this value to 1. For the default behavior, do not provide the property.

    <property name="mq.target.client">1</property>

    Some JMS vendors (for example, IBM MQ) require a JMS Session for each topic or queue subscription. The default configuration for the JMS adapter does not allow for this, but you can enable it by setting the use.global.session property to false in Publishers.xml:

    <property name="use.global.session">false</property>
    Table 1. Properties that can be specified when configuring the JMS adapter
    <env> All properties within the <env> tag of JMSAdapter51.xml are used when creating the InitialContext which is in turn used to create the connection to the JMS server.
    <connection-factory> This tag specifies the name of the connection factory to use. This varies between JMS vendors and the server configuration.
    <credentials> Optionally, specify a username and/or password which is used to create a JMS client connection. However, most JMS implementations are likely to have restricted access for anonymous clients or clients which do not require authentication so you can specify a user here who has the necessary privileges to receive and send messages to the JMS destinations that are exposed through Diffusion™.
    <reconnect> If a connection cannot be made between Diffusion and the JMS server or the connection is severed, the <max-reconnections> and <interval> parameters enable you to specify how many times to retry the connection before giving up and how long to wait between each attempt. A value for <max-reconnections> of -1 indicates that the adapter keeps trying to connect forever.
    <root-topic> To provide partitioning of the topic tree between topics related to JMS and other topics, it is necessary for a root topic name is defined here. In the event of more than one JMS adapter, you can segment the topic tree further.
    <priority> JMS supports messages with up to 10 priority levels (0-9) with 0-4 considered to be different grades of normal priority and 5-9 to be different grades of high priority. Diffusion only has the concept of low, medium and high priority. Using this parameter, you can map JMS messages within a given priority range to a representative Diffusion priority, and in the other direction.
    <queue-distribution-mode> Unlike topics, a message on a JMS queue is delivered to only one client. When Diffusion receives a message from a queue, it uses this parameter to determine which of its connected clients subscribed to the corresponding Diffusion topic is selected to receive that message. Valid values are:
    SMALLEST_QUEUE
    Choose a client with the fewest number of messages outstanding in its message queue from Diffusion.
    RANDOM
    Select a client randomly.
    <artefact-names> Not all characters in a Diffusion topic name are valid JMS topic or queue names (and the other way around). The two attributes on this element (jms and diffusion) are lists of characters where the nth character in one is replaced by the corresponding nth character in the other.