Red Hat AMQ 6
As of February 2025, Red Hat is no longer supporting Red Hat AMQ 6. If you are using AMQ 6, please upgrade: Migrating to AMQ 7.10.3. Native ActiveMQ JMS-to-JMS Bridge
10.3.1. Embedded Native Configuration Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Spring configuration Copy linkLink copied to clipboard!
jmsBridgeConnectors element, which can contain any number of jmsQueueConnector elements and jmsTopicConnector elements. The detailed configuration of the bridge is described in the following sections.
Example 10.2. Embedded native JMS-to-JMS Bridge
Router rules Copy linkLink copied to clipboard!
Figure 10.2. Routing Rules in the JMS-to-JMS Bridge
Rule types Copy linkLink copied to clipboard!
- Inbound queue-to-queue mapping—defines a rule for pulling messages off a queue in the third-party JMS provider and forwarding the messages to a queue (possibly with a different name) in the ActiveMQ broker.
- Outbound queue-to-queue mapping—defines a rule for pulling messages off a queue in the ActiveMQ broker and forwarding the messages to a queue (possibly with a different name) in the third-party JMS provider.
- Inbound topic-to-topic mapping—defines a rule for receiving messages from a topic in the third-party JMS provider and forwarding the messages to a topic (possibly with a different name) in the ActiveMQ broker.
- Outbound topic-to-topic mapping—defines a rule for receiving messages from a topic in the ActiveMQ broker and forwarding the messages to a topic (possibly with a different name) in the third-party JMS provider.
10.3.2. Connecting to the ActiveMQ Broker Copy linkLink copied to clipboard!
Bootstrapping an embedded bridge Copy linkLink copied to clipboard!
Non-embedded deployments Copy linkLink copied to clipboard!
jmsQueueConnector supports various attributes (localQueueConnection, localQueueConnectionFactory, and so on), which you can use to configure the ActiveMQ broker connection explicitly. Likewise, the jmsTopicConnector element supports attributes for configuring an ActiveMQ broker connection explicitly. This type of deployment lies beyond the scope of the current guide. We recommend that you use an embedded deployment of the native JMS-to-JMS bridge.
10.3.3. Connecting to the Third-Party JMS Provider Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Reference a connection factory bean Copy linkLink copied to clipboard!
javax.jms.QueueConnectionFactory instance directly as a Spring bean. You can then reference this bean from the native JMS-to-JMS bridge by setting the outboundQueueConnectionFactory attribute of the jmsQueueConnector element.
jmsTopicConnector element by setting the outboundTopicConnectionFactory attribute to reference a javax.jms.TopicConnectionFactory instance.
Look up a connection factory in JNDI Copy linkLink copied to clipboard!
javax.jms.QueueConnectionFactory instance in a JNDI directory (assuming that some administrative tool has already instantiated and registered the connection factory in JNDI).
jndiOutboundTemplate attribute references an org.springframework.jndi.JndiTemplate bean instance, which is a Spring wrapper class that configures a JNDI directory. In this example, the JNDI directory is LDAP based, so the JndiTemplate bean is configured with the URL for connecting to the LDAP server. The outboundQueueConnectionFactoryName attribute specifies a query on the LDAP server, which should return a javax.jms.QueueConnectionFactory instance.
10.3.4. Configuring Queue Bridges Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
inboundQueueBridges element and the outboundQueueBridges element. Using these elements, you can specify which queues to bridge between the third-party JMS provider and the ActiveMQ broker.
Inbound queue bridges Copy linkLink copied to clipboard!
inboundQueueBridges element and the inboundQueueBridge child elements are used to route queue messages from the third-party JMS provider to the ActiveMQ broker. In this case, inbound means heading into the ActiveMQ broker.
<inboundQueueBridges> <inboundQueueBridge inboundQueueName="QueueA" /> </inboundQueueBridges>
<inboundQueueBridges>
<inboundQueueBridge inboundQueueName="QueueA" />
</inboundQueueBridges>
QueueA queue on the third-party JMS provider and pushes the messages on to the QueueA queue on the ActiveMQ broker.
<inboundQueueBridges>
<inboundQueueBridge
inboundQueueName="QueueA"
localQueueName="org.activemq.example.QueueA" />
</inboundQueueBridges>
<inboundQueueBridges>
<inboundQueueBridge
inboundQueueName="QueueA"
localQueueName="org.activemq.example.QueueA" />
</inboundQueueBridges>
inboundQueueName specifies the name of the queue on the third-party JMS provider and localQueueName specifies the name of the queue on the ActiveMQ broker.
Outbound queue bridges Copy linkLink copied to clipboard!
outboundQueueBridges element and the outboundQueueBridge child elements are used to route queue messages from the ActiveMQ broker to the third-party JMS provider. In this case, outbound means heading away from the ActiveMQ broker.
<outboundQueueBridges> <outboundQueueBridge outboundQueueName="QueueX" /> </inboundQueueBridges>
<outboundQueueBridges>
<outboundQueueBridge outboundQueueName="QueueX" />
</inboundQueueBridges>
QueueX queue on the ActiveMQ broker and pushes the messages on to the QueueX queue on the third-party JMS provider.
<outboundQueueBridges>
<outboundQueueBridge
outboundQueueName="QueueX"
localQueueName="org.activemq.example.QueueX" />
</inboundQueueBridges>
<outboundQueueBridges>
<outboundQueueBridge
outboundQueueName="QueueX"
localQueueName="org.activemq.example.QueueX" />
</inboundQueueBridges>
outboundQueueName specifies the name of the queue on the third-party JMS provider and localQueueName specifies the name of the queue on the ActiveMQ broker.
Sample queue bridges Copy linkLink copied to clipboard!
QueueA, QueueB, and QueueC, and three outbound queues, QueueX, QueueY, and QueueZ.
Example 10.3. Sample Queue Bridges
10.3.5. Configuring Topic Bridges Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
inboundTopicBridges element and the outboundTopicBridges element. Using these elements, you can specify which topics to bridge between the third-party JMS provider and the ActiveMQ broker.
Inbound topic bridges Copy linkLink copied to clipboard!
inboundTopicBridges element and the inboundTopicBridge child elements are used to route topic messages from the third-party JMS provider to the ActiveMQ broker. In this case, inbound means heading into the ActiveMQ broker.
<inboundTopicBridges> <inboundTopicBridge inboundTopicName="TopicA" /> </inboundTopicBridges>
<inboundTopicBridges>
<inboundTopicBridge inboundTopicName="TopicA" />
</inboundTopicBridges>
TopicA topic on the third-party JMS provider and pushes the messages on to the TopicA topic on the ActiveMQ broker.
<inboundTopicBridges>
<inboundTopicBridge
inboundTopicName="TopicA"
localTopicName="org.activemq.example.TopicA" />
</inboundTopicBridges>
<inboundTopicBridges>
<inboundTopicBridge
inboundTopicName="TopicA"
localTopicName="org.activemq.example.TopicA" />
</inboundTopicBridges>
inboundTopicName specifies the name of the topic on the third-party JMS provider and localTopicName specifies the name of the topic on the ActiveMQ broker.
Outbound topic bridges Copy linkLink copied to clipboard!
outboundTopicBridges element and the outboundTopicBridge child elements are used to route topic messages from the ActiveMQ broker to the third-party JMS provider. In this case, outbound means heading away from the ActiveMQ broker.
<outboundTopicBridges> <outboundTopicBridge outboundTopicName="TopicX" /> </inboundTopicBridges>
<outboundTopicBridges>
<outboundTopicBridge outboundTopicName="TopicX" />
</inboundTopicBridges>
TopicX topic on the ActiveMQ broker and pushes the messages on to the TopicX topic on the third-party JMS provider.
<outboundTopicBridges>
<outboundTopicBridge
outboundTopicName="TopicX"
localTopicName="org.activemq.example.TopicX" />
</inboundTopicBridges>
<outboundTopicBridges>
<outboundTopicBridge
outboundTopicName="TopicX"
localTopicName="org.activemq.example.TopicX" />
</inboundTopicBridges>
outboundTopicName specifies the name of the topic on the third-party JMS provider and localTopicName specifies the name of the topic on the ActiveMQ broker.
Sample topic bridges Copy linkLink copied to clipboard!
TopicA, TopicB, and TopicC, and three outbound topics, TopicX, TopicY, and TopicZ.
Example 10.4. Sample Topic Bridges
10.3.6. Deploying a Bridge Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Deploy the Third-Party Client Libraries Copy linkLink copied to clipboard!
wrap: URL prefix.
foo-jms-client.jar located in the /tmp directory, you could deploy it into the OSGi container as follows:
JBossA-MQ:karaf@root> osgi:install -s wrap:file:///tmp/foo-jms-client.jar
JBossA-MQ:karaf@root> osgi:install -s wrap:file:///tmp/foo-jms-client.jar
wrap: prefix.
Deploy the Bridge Copy linkLink copied to clipboard!
InstallDir/etc/activemq.xml file, and insert the jmsBridgeConnectors element as a child of the broker element, as follows:
10.3.7. Sample Bridge Configuration Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
ActiveMQ-to-WebSphere MQ bridge Copy linkLink copied to clipboard!
InstallDir/etc/activemq.xml file.
Example 10.5. ActiveMQ-to-WebSphere MQ Configuration
QueueA queue and a QueueX queue on the WebSphere MQ server. ActiveMQ will create the corresponding queues dynamically—there is no need to create them in advance.
Deploying the WebSphere MQ client libraries Copy linkLink copied to clipboard!
$MQ_INSTALL_DIR/java/lib/OSGI
$MQ_INSTALL_DIR/java/lib/OSGI
install commands:
10.3.8. Handling ReplyTo Destinations Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
ReplyTo destinations Copy linkLink copied to clipboard!
JMSReplyTo header, which specifies the Destination (Queue or Topic) on which the sender expects to receive a reply.
Automatic proxification Copy linkLink copied to clipboard!
JMSReplyTo header, a corresponding rule must be put in place to ensure that the reply message is propagated back through the bridge. In general, the most effective approach is for the bridge to create the required rule dynamically, whenever a JMSReployTo header is encountered.
M1, where the ReplyTo destination is a queue named ReplyA.
Figure 10.3. Automatic Proxification in the native JMS-to-JMS Bridge
10.3.9. Implementing Message Convertors Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
- Inbound message convertor—converts third-party JMS messages to ActiveMQ messages.
- Outbound message convertor—converts ActiveMQ messages to third-party JMS messages.
JmsMessageConvertor interface Copy linkLink copied to clipboard!
JmsMessageConvertor interface, which can be used as the basis for implementing either an inbound message convertor or an outbound message convertor.
Example 10.6. JmsMessageConvertor interface
Message converter methods Copy linkLink copied to clipboard!
JmsMesageConvertor interface exposes the following methods:
Message convert(Message message)- This variant of the
convertmethod is called, if thedoHandleReplyTooption is set tofalseor if theReplyTodestination on the message isnull. In this case, theconvertmethod should simply reformat the message content as required. Message convert(Message message, Destination replyTo)- This variant of the
convertmethod is called, if theReplyTodestination on the message is non-null. In this case, in addition to reformatting the message, you have the ability to change thereplyTodestination, so that the reply to this message is redirected to a different destination.ThereplyToargument contains the original destination of the message. If you want to change the ReplyTo destination, you can do so by calling themessage.setJMSReplyTo()method, passing in the changed destination.The reason you might want to change the ReplyTo destination is in order to take control of proxification (see Section 10.3.8, “Handling ReplyTo Destinations”). Proxification is necessary, because the ActiveMQ broker is not able to make a direct connection back to the third-party JMS provider. void setConnection(Connection connection)- Provides a reference to the
javax.jms.Connectionobject to which messages will be forwarded. In other words, if this message convertor is used as an inbound message convertor, this connection is the connection to the ActiveMQ broker. If this message convertor is used as an outbound message convertor, this connection is the connection to the third-party JMS provider.
Sample implementation Copy linkLink copied to clipboard!
Example 10.7. Sample Message Convertor
Configuring the message convertor Copy linkLink copied to clipboard!
inboundMessageConvertor and outboundMessageConvertor attributes.
SimpleJmsMessageConvertor implementation both as an inbound message convertor and as an outbound message convertor, you could configure a JMS queue connector as follows:
10.3.10. Configuration Reference Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
jmsQueueConnector attributes Copy linkLink copied to clipboard!
jmsQueueConnector element:
id- Optional beran ID of
xs:IDtype, which could be used to reference this bean. inboundMessageConvertor- References a bean instance of
org.apache.activemq.network.jms.JmsMesageConvertortype, which transforms inbound messages from the third-party JMS provider into a format that is suitable for the ActiveMQ broker. jndiLocalTemplate- References a bean instance of
org.springframework.jndi.JndiTemplatetype, which provides access to a JNDI directory instance. Used in combination with thelocalConnectionFactoryNameattribute to locate a JMSQueueConnectionFactoryinstance in a JNDI directory, where this connection factory instance is then used to connect to the local JMS provider (that is, the ActiveMQ broker). jndiOutboundTemplate- References a bean instance of
org.springframework.jndi.JndiTemplatetype, which provides access to a JNDI directory instance. Used in combination with theoutboundQueueConnectionFactoryNameattribute to locate a JMSQueueConnectionFactoryinstance in a JNDI directory, where this connection factory instance is then used to connect to the third-party JMS provider. localClientId- Sets the ID of the local connection (useful for logging and JMX monitoring).
localConnectionFactoryName- Specifies the JNDI name of a
QueueConnectionFactoryinstance. Used in combination with thejndiLocalTemplateattribute to connect to the local JMS provider (that is, the ActiveMQ broker). localPassword- Specifies the password part of the credentials used to log on to the local JMS provider (ActiveMQ broker). Used in combination with the
localUsernameattribute. localQueueConnection- References a bean of
javax.jms.QueueConnectiontype, which is used to connect to the local JMS provider (ActiveMQ broker). localQueueConnectionFactory- References a bean of
javax.jms.QueueConnectionFactorytype, which is used to connect to the local JMS provider (ActiveMQ broker). localUsername- Specifies the username part of the credentials used to log on to the local JMS provider (ActiveMQ broker). Used in combination with the
localPasswordattribute. name- Assigns a name to this
jmsQueueConnectorelement (useful for logging and JMX monitoring). outboundClientId- Sets the ID of the third-party connection (useful for logging and JMX monitoring).
outboundMessageConvertor- References a bean instance of
org.apache.activemq.network.jms.JmsMesageConvertortype, which transforms outbound messages from the ActiveMQ broker into a format that is suitable for the third-party JMS provider. outboundPassword- Specifies the password part of the credentials used to log on to the third-party JMS provider. Used in combination with the
outboundUsernameattribute. outboundQueueConnection- References a bean of
javax.jms.QueueConnectiontype, which is used to connect to the third-party JMS provider. outboundQueueConnectionFactory- References a bean of
javax.jms.QueueConnectionFactorytype, which is used to connect to the third-party JMS provider. outboundQueueConnectionFactoryName- Specifies the JNDI name of a
QueueConnectionFactoryinstance. Used in combination with thejndiOutboundTemplateattribute to connect to the third-party JMS provider. outboundUsername- Specifies the username part of the credentials used to log on to the third-party JMS provider. Used in combination with the
outboundPasswordattribute. preferJndiDestinationLookup- Specifies whether the connector should first try to find a destination in JNDI before using JMS semantics to create a
Destination. By default, the connector will first use JMS semantics and then fall back to JNDI look-up. Setting this attribute totruereverses that order.
jmsTopicConnector attributes Copy linkLink copied to clipboard!
jmsTopicConnector element:
id- Optional bean ID of
xs:IDtype, which could be used to reference this bean. inboundMessageConvertor- References a bean instance of
org.apache.activemq.network.jms.JmsMesageConvertortype, which transforms inbound messages from the third-party JMS provider into a format that is suitable for the ActiveMQ broker. jndiLocalTemplate- References a bean instance of
org.springframework.jndi.JndiTemplatetype, which provides access to a JNDI directory instance. Used in combination with thelocalConnectionFactoryNameattribute to locate a JMSTopicConnectionFactoryinstance in a JNDI directory, where this connection factory instance is then used to connect to the local JMS provider (that is, the ActiveMQ broker). jndiOutboundTemplate- References a bean instance of
org.springframework.jndi.JndiTemplatetype, which provides access to a JNDI directory instance. Used in combination with theoutboundTopicConnectionFactoryNameattribute to locate a JMSTopicConnectionFactoryinstance in a JNDI directory, where this connection factory instance is then used to connect to the third-party JMS provider. localClientId- Sets the ID of the local connection (useful for logging and JMX monitoring).
localConnectionFactoryName- Specifies the JNDI name of a
TopicConnectionFactoryinstance. Used in combination with thejndiLocalTemplateattribute to connect to the local JMS provider (that is, the ActiveMQ broker). localPassword- Specifies the password part of the credentials used to log on to the local JMS provider (ActiveMQ broker). Used in combination with the
localUsernameattribute. localTopicConnection- References a bean of
javax.jms.TopicConnectiontype, which is used to connect to the local JMS provider (ActiveMQ broker). localTopicConnectionFactory- References a bean of
javax.jms.TopicConnectionFactorytype, which is used to connect to the local JMS provider (ActiveMQ broker). localUsername- Specifies the username part of the credentials used to log on to the local JMS provider (ActiveMQ broker). Used in combination with the
localPasswordattribute. name- Assigns a name to this
jmsTopicConnectorelement (useful for logging and JMX monitoring). outboundClientId- Sets the ID of the third-party connection (useful for logging and JMX monitoring).
outboundMessageConvertor- References a bean instance of
org.apache.activemq.network.jms.JmsMesageConvertortype, which transforms outbound messages from the ActiveMQ broker into a format that is suitable for the third-party JMS provider. outboundPassword- Specifies the password part of the credentials used to log on to the third-party JMS provider. Used in combination with the
outboundUsernameattribute. outboundTopicConnection- References a bean of
javax.jms.TopicConnectiontype, which is used to connect to the third-party JMS provider. outboundTopicConnectionFactory- References a bean of
javax.jms.TopicConnectionFactorytype, which is used to connect to the third-party JMS provider. outboundTopicConnectionFactoryName- Specifies the JNDI name of a
TopicConnectionFactoryinstance. Used in combination with thejndiOutboundTemplateattribute to connect to the third-party JMS provider. outboundUsername- Specifies the username part of the credentials used to log on to the third-party JMS provider. Used in combination with the
outboundPasswordattribute. preferJndiDestinationLookup- Specifies whether the connector should first try to find a destination in JNDI before using JMS semantics to create a
Destination. By default, the connector will first use JMS semantics and then fall back to JNDI look-up. Setting this attribute totruereverses that order.
inboundQueueBridge attributes Copy linkLink copied to clipboard!
inboundQueueBridge element:
doHandleReplyTo- A boolean attribute that specifies whether ReplyTo messages should be handled or not. Default is
true. id- Optional bean ID of
xs:IDtype, which could be used to reference this bean. inboundQueueName- Specifies the name of the queue in the third-party JMS provider, from which messages are consumed.
localQueueName- Specifies the local queue name (in the ActiveMQ broker), into which messages are pushed. If not specified, defaults to the same value as
inboundQueueName. selector- Optionally, specifies a JMS selector string.
outboundQueueBridge attributes Copy linkLink copied to clipboard!
outboundQueueBridge element:
doHandleReplyTo- A boolean attribute that specifies whether ReplyTo messages should be handled or not. Default is
true. id- Optional bean ID of
xs:IDtype, which could be used to reference this bean. outboundQueueName- Specifies the name of the queue in the third-party JMS provider, into which messages are pushed.
localQueueName- Specifies the local queue name (in the ActiveMQ broker), from which messages are consumed. If not specified, defaults to the same value as
outboundQueueName. selector- Optionally, specifies a JMS selector string.
inboundTopicBridge attributes Copy linkLink copied to clipboard!
inboundTopicBridge element:
consumerName- If this attribute is set, the bridge creates a durable consumer for this topic.
doHandleReplyTo- A boolean attribute that specifies whether ReplyTo messages should be handled or not. Default is
true. id- Optional bean ID of
xs:IDtype, which could be used to reference this bean. inboundTopicName- Specifies the name of the topic in the third-party JMS provider, from which messages are consumed.
localTopicName- Specifies the local topic name (in the ActiveMQ broker), into which messages are pushed. If not specified, defaults to the same value as
inboundTopicName. selector- Optionally, specifies a JMS selector string.
outboundTopicBridge attributes Copy linkLink copied to clipboard!
outboundTopicBridge element:
consumerName- If this attribute is set, the bridge creates a durable consumer for this topic.
doHandleReplyTo- A boolean attribute that specifies whether ReplyTo messages should be handled or not. Default is
true. id- Optional bean ID of
xs:IDtype, which could be used to reference this bean. outboundTopicName- Specifies the name of the topic in the third-party JMS provider, into which messages are pushed.
localTopicName- Specifies the local topic name (in the ActiveMQ broker), from which messages are consumed. If not specified, defaults to the same value as
outboundTopicName. selector- Optionally, specifies a JMS selector string.