Skip to Content

Enable RabbitMQ Provider with JMS

Introduction

By default, the Harmony JMS Connector establishes access to JMS using ActiveMQ. Additional JMS providers can also be used. This page summarizes how to establish access to JMS using RabbitMQ.

Note

A RabbitMQ provider can be used only with projects that use Harmony Private Agents.

Prerequisites

These JAR files must be downloaded onto your Private Agent as described below:

  • amqp-client-5.8.0.jar
  • fscontext-4.6-b01.jar
  • geronimo-jms_1.1_spec-1.1.1.jar
  • rabbitmq-jms-2.1.0.jar
  • slf4j-api-1.7.30.jar

A .bindings file must be created with these definitions:

.bindings
# Define the Connection Factory object
ConnectionFactory/ClassName=javax.jms.ConnectionFactory
ConnectionFactory/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory
ConnectionFactory/RefAddr/0/Content=jms/ConnectionFactory
ConnectionFactory/RefAddr/0/Type=name
ConnectionFactory/RefAddr/0/Encoding=String
ConnectionFactory/RefAddr/1/Content=javax.jms.ConnectionFactory
ConnectionFactory/RefAddr/1/Type=type
ConnectionFactory/RefAddr/1/Encoding=String
ConnectionFactory/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory
ConnectionFactory/RefAddr/2/Type=factory
ConnectionFactory/RefAddr/2/Encoding=String

# Define the location of the broker, likely localhost, and the VirtualHost these resources will reside in
# Replace HOST_NAME with the host name for RabbitMQ
ConnectionFactory/RefAddr/3/Content=HOST_NAME
ConnectionFactory/RefAddr/3/Type=host
ConnectionFactory/RefAddr/3/Encoding=String
ConnectionFactory/RefAddr/4/Content=regression
ConnectionFactory/RefAddr/4/Type=virtualHost
ConnectionFactory/RefAddr/4/Encoding=String

# Define an example Queue
queue1/ClassName=javax.jms.Queue
queue1/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory
queue1/RefAddr/0/Content=jms/Queue
queue1/RefAddr/0/Type=name
queue1/RefAddr/0/Encoding=String
queue1/RefAddr/1/Content=javax.jms.Queue
queue1/RefAddr/1/Type=type
queue1/RefAddr/1/Encoding=String
queue1/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory
queue1/RefAddr/2/Type=factory
queue1/RefAddr/2/Encoding=String
queue1/RefAddr/3/Content=queue1
queue1/RefAddr/3/Type=destinationName
queue1/RefAddr/3/Encoding=String

Enabling RabbitMQ with JMS

Follow these steps to enable RabbitMQ with JMS:

  1. Navigate to Jitterbit Agent > Connectors > JMS > Providers. In the Providers directory, create a new folder named RabbitMQ. To this folder add the .bindings file with the updated HOST_NAME and the JAR files listed in Prerequisites.

  2. Navigate to <JITTERBIT_HOME>/Connectors/JMS, replacing <JITTERBIT_HOME> with your Private Agent root directory. Your Private Agent root directory is usually in one of these default locations:

    • Windows: C:\Program Files\Jitterbit Agent
    • Linux: /opt/jitterbit
  3. Add a new <Provider> element to JMS_ProviderInfo_User.conf with these entries:

    Field Description
    <name> The name of the provider. The name must be unique. This name will show up in the JMS Provider connection parameter when configuring a JMS endpoint.
    <java.naming.factory.initial> The value of this JNDI property must be the fully qualified class name of the factory class that will create an initial context.
    <java.naming.provider.url> The value of this JNDI property must be the path of the RabbitMQ folder created in step 1.
    <factoryName> The name of the connection factory that has been configured on the service provider.
    <pathOfProviderJars> The absolute path of the directory where the provider JAR files are placed in step 1.

    These are examples of the <Provider> element to be added to JMS_ProviderInfo_User.conf:

    Windows Example
    <Provider>
    <Name>RabbitMQ</Name>
    <java.naming.factory.initial>com.sun.jndi.fscontext.RefFSContextFactory</java.naming.factory.initial>
    <java.naming.provider.url>C:\Program Files\Jitterbit Agent\Connectors\JMS\Providers\RabbitMQ</java.naming.provider.url>
    <factoryName>ConnectionFactory</factoryName>
    <pathOfProviderJars>C:\Program Files\Jitterbit Agent\Connectors\JMS\Providers\RabbitMQ</pathOfProviderJars>
    </Provider>
    
    Linux Example
    <Provider>
    <Name>RabbitMQ</Name>
    <java.naming.factory.initial>com.sun.jndi.fscontext.RefFSContextFactory</java.naming.factory.initial>
    <java.naming.provider.url>file://localhost/opt/jitterbit/Connectors/JMS/Providers/RabbitMQ</java.naming.provider.url>
    <factoryName>ConnectionFactory</factoryName>
    <pathOfProviderJars>/opt/jitterbit/Connectors/JMS/Providers/RabbitMQ</pathOfProviderJars>
    </Provider>
    

    Note

    These entries should be placed at the bottom of JMS_ProviderInfo_User.conf between the arrow --> and </Providers>.

  4. Restart the agent:

  5. Once the agent is running, you will be able to create a new JMS endpoint with the option to select RabbitMQ as the provider:

    attachment

For more information on creating JMS endpoints, see JMS Connector Creating Endpoints.