Chapter 8. JBoss Messaging Message Bridge Configuration

8.1. Message Bridge Overview

JBoss Messaging includes a fully functional message bridge.
The bridge consumes messages from a source queue or topic and sends them to a target queue or topic, typically on a different server. The source and target servers do not need to be in the same cluster, so bridging is a reliable method of sending messages from one cluster to another (across a WAN, for example) and where the connection may be unreliable.
A bridge is deployed as a managed bean within any JBoss Enterprise Application Platform instance. To deploy, add the managed bean descriptor into the deploy directory of an Enterprise Application Platform configuration that contains JBoss Messaging.
The example in $JBOSS_HOME/docs/examples/jboss-messaging-examples/bridge/ demonstrates a simple bridge deployed in JBoss Enterprise Application Platform and moving messages from the source to the target destination.
The bridge can also be used to retrieve messages from other non-JBoss Messaging JMS servers as long as they are JMS 1.1 compliant.
The bridge has built-in failure recovery; if the source or target server connection is lost, the bridge will attempt to reconnect to the source or target until it comes back online, at which point normal operation will resume.
The bridge can be configured to consume messages matching a particular JMS selector.
It can be configured to consume from a queue or a topic. When the bridge consumes from a topic, it can be configured to consume with a non-durable or a durable subscription.
The bridge can be configured to handle messages with one of three quality of service (QoS) levels:

Bridge QoS Levels

QOS_AT_MOST_ONCE
This mode specifies that messages will arrive at the destination once at the most. Messages are consumed from the source and acknowledged before they are sent to the destination. Messages can be lost if failure occurs between the message leaving the source and arriving at the destination. Messages will therefore be delivered once at most.
This mode is available for both persistent and non-persistent messages.
QOS_DUPLICATES_OK
This mode specifies that messages are consumed from the source and acknowledged after they have been successfully sent to the destination. If failure occurs between a message arriving, and being acknowledged by the destination, that message is sent a second time when the system recovers.
This mode is available for both persistent and non-persistent messages.
QOS_ONCE_AND_ONLY_ONCE
This mode specifies that messages will arrive exactly once. When the message source and destination are on the same JBoss Messaging server instance, the message can be sent and received in the same local transaction.
If the source and destination are on different servers, you can implement message high durability by using a JTA transaction controlled by JBoss Transactions JTA implementation. If JTA is required, both connection factories must be XAConnectionFactory implementations.
This mode is only available for persistent messages.
This mode requires logging on both the transaction manager and the resource side to support recovery. If you require this level of QOS, you must enable XA Recovery with JBoss Transactions.

Note

You may be able to apply once and only once semantics to a specific application, without setting QOS_ONCE_AND_ONLY_ONCE. Set QOS_DUPLICATES_OK mode, and then check for and discard duplicate messages at the destination.
You can implement QOS_ONCE_AND_ONLY_ONCE behaviour at the application level by maintaining a cache of received message IDs on disk and comparing received messages to this cache. Because the cache would only be valid for a certain period of time, this approach is not infallible, but can be a useful alternative depending on your application.