8.3. Bridge Configuration
The following code is an example configuration of the message bridge, showing all attributes. Some attributes have been commented out for this configuration, since not all attributes should be specified at once. Those attributes that
Example 8.1. Message Bridge Configuration
<mbean code="org.jboss.jms.server.bridge.BridgeService" name="jboss.messaging:service=Bridge,name=TestBridge" xmbean-dd="xmdesc/Bridge-xmbean.xml"> <!-- The JMS provider loader that is used to lookup the source destination --> <depends optional-attribute-name="SourceProviderLoader"> jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends> <!-- The JMS provider loader that is used to lookup the target destination --> <depends optional-attribute-name="TargetProviderLoader"> jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends> <!-- The JNDI lookup for the source destination --> <attribute name="SourceDestinationLookup">/queue/A</attribute> <!-- The JNDI lookup for the target destination --> <attribute name="TargetDestinationLookup">/queue/B</attribute> <!-- The username to use for the source connection <attribute name="SourceUsername">bob</attribute> --> <!-- The password to use for the source connection <attribute name="SourcePassword">BobSecur3</attribute> --> <!-- The username to use for the target connection <attribute name="TargetUsername">mary</attribute> --> <!-- The password to use for the target connection <attribute name="TargetPassword">MaryS3cur3</attribute> --> <!-- Optional: The Quality Of Service mode to use, one of: QOS_AT_MOST_ONCE = 0; QOS_DUPLICATES_OK = 1; QOS_ONCE_AND_ONLY_ONCE = 2; --> <attribute name="QualityOfServiceMode">0</attribute> <!-- JMS selector to use for consuming messages from the source <attribute name="Selector">specify jms selector here</attribute> --> <!-- The maximum number of messages to consume from the source before sending to the target --> <attribute name="MaxBatchSize">5</attribute> <!-- The maximum time to wait (in ms) before sending a batch to the target even if MaxBatchSize is not exceeded. -1 means wait forever --> <attribute name="MaxBatchTime">-1</attribute> <!-- If consuming from a durable subscription this is the subscription name <attribute name="SubName">mysub</attribute> --> <!-- If consuming from a durable subscription this is the client ID to use <attribute name="ClientID">myClientID</attribute> --> <!-- The number of ms to wait between connection retrues in the event connections to source or target fail --> <attribute name="FailureRetryInterval">5000</attribute> <!-- The maximum number of connection retries to make in case of failure, before giving up -1 means try forever --> <attribute name="MaxRetries">-1</attribute> <!-- If true then the message ID of the message before bridging will be added as a header to the message so it is available to the receiver. Can then be sent as correlation ID to correlate in a distributed request-response --> <attribute name="AddMessageIDInHeader">false</attribute> </mbean>
Message Bridge Configuration Attributes
- SourceProviderLoader, TargetProvider Loader
- The
JMSProviderLoader
managed bean is used by the bridge to look up the source connection factory and source destination. By default, JBoss Enterprise Application Platform ships with oneJMSProviderLoader
, which is deployed in the$JBOSS_HOME/server/$PROFILE/deploy/messaging/jms-ds.xml
file, and serves as the default localJMSProviderLoader
. For a clustered configuration,hajndi-jms-ds.xml
performs the same role.If your source or target destination is on a different server, or corresponds to a non-JBoss JMS Provider, you can deploy anotherJMSProviderLoader
managed bean instance that the bridge can use to contact the destination on the remote JMS Provider.To useQOS_ONCE_AND_ONLY_ONCE
delivery with a remote non-JBoss Messaging source or target, the remote JMS Provider must provide a fully-functional JMS XA resource implementation that works remotely from the server. - SourceDestinationLookup
- The full JNDI lookup for the source destination, via the
SourceProviderLoader
, such as/queue/mySourceQueue
. - TargetDestinationLookup
- The full JNDI lookup for the target destination, via the
TargetProviderLocator
, such as/topic/myTargetTopic
. - SourceUsername
- An optional attribute that specifies the username used when creating the source connection.
- SourcePassword
- An optional attribute that specifies the password used when creating the source connection.
- TargetUsername
- An optional attribute that specifies the username used when creating the target connection.
- TargetPassword
- An optional attribute that specifies the password used when creating the target connection.
- QualityOfServiceMode
- An integer representing the desired quality of service mode. The possible values are:
0
to representQOS_AT_MOST_ONCE
1
to representQOS_DUPLICATES_OK
2
to representQOS_ONCE_AND_ONLY_ONCE
See Section 8.1, “Message Bridge Overview” for a complete explanation of these modes. - Selector
- An optional attribute that lets you provide a JMS selector expression when consuming messages from a source destination. Only messages that match the selector expression are bridged from the source to the target destination. The selector expression must follow the JMS selector syntax, specified here: http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Message.html.For optimal performance, apply source topic subscription selectors to source queue consumers.
- MaxBatchSize
- Specifies the maximum number of messages to consume from the source destination before sending a message batch to the target destination. Its value must be greater than or equal to
1
. - MaxBatchTime
- Specifies the longest period (in milliseconds) to wait before sending a message batch to the target, even if the
MaxBatchSize
has not been reached. Its value must be either-1
(wait forever) or greater than or equal to1
to specify a time. - SubName
- Represents the name of the durable subscription that will consume from the source destination topic.
- ClientID
- Represents the JMS client ID to use when creating or looking up the durable subscription that will consume from the source destination topic.
- FailureRetryInterval
- The period of time (in milliseconds) to wait between attempting to recreate the connection to the source or target server after failure is detected.
- MaxRetries
- The number of times to attempt to recreate the connection to the source or target server after failure is detected. The bridge will then stop attempting to recreate the connection. A value of
-1
means that the bridge will continue to attempt to reconnect forever. - AddMessageIDInHeader
- When
true
, the original message ID is added to theJBossMessage.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST
header of the message being sent to the destination. If the message is bridged multiple times, each message ID is added to the header. This enables a distributed request-response pattern.