Bridges is another feature of TIBCO EMS which gives the opportunity to send messages to multiple subscribers from a producer. Also, it’s possible to filter the messages for each consumer.

Bridges are created between one destination and one or more other destinations of the same or of different types. That is, you can create a bridge from a topic to a queue or from a queue to a topic. Also, you can create a bridge to a destination from a different source. i.e if you have topics named TEST1.TOPIC and TEST2.TOPIC, you can create a bridge from both these topic to a queue.

Note: Because global topics are routed between servers and queues are limited to their neighbors, in most cases, the best practice is to send messages to a topic and then bridge the topic to a queue.

tcp://EMS01:7020> create bridge source=topic:TEST1.TOPIC target=queue:APP1.QUEUE
Bridge has been created
tcp://EMS01:7020> create bridge source=topic:TEST2.TOPIC target=queue:APP1.QUEUE
Bridge has been created

tcp://EMS01:7020> show topic TEST1.TOPIC
 Topic:                 TEST1.TOPIC
 Type:                  static
 Properties:            *prefetch=64,*store=$sys.nonfailsafe
 JNDI Names:            <none>
 Bridges:               queue=APP1.QUEUE

tcp://EMS01:7020> show topic TEST2.TOPIC
 Topic:                 TEST2.TOPIC
 Type:                  static
 Properties:            *prefetch=64,*store=$sys.nonfailsafe
 JNDI Names:            <none>
 Bridges:               queue=APP1.QUEUE

How to create a bridge?

Syntax : create bridge source=<type>:<name> 
                       target=<type>:<name>
                       [selector=<selector>]

tcp://EMS01:7020> create bridge source=topic:TEST1.TOPIC 
                                target=queue:TEST1.QUEUE
Bridge has been created

<type> is one of ‘topic’ or ‘queue’, <name> is destination name. the selector is optional and it is used to filter the message. For example, the publisher sends the message for APP1 and APP2 to topic TEST1.TOPIC and we can filter the message using the selector and decide which destination should receive the message.

What is the Selector in a bridge?

Consider I have another queue named APP2.QUEUE as well and it bridged to TEST1.TOPIC and I want to send the messages for APP1 to APP1.QUEUE and APP2 messages to APP2.QUEUE, then I can add the below configuration to make it possible.

tcp://EMS01:7020> create bridge source=topic:TEST1.TOPIC 
                                target=queue:APP1.QUEUE 
                                selector="JMSCorrelationID='APP1'"
Bridge has been created
tcp://EMS01:7020> create bridge source=topic:TEST1.TOPIC 
                                target=queue:APP2.QUEUE 
                                selector="JMSCorrelationID in ('APP2')"
Bridge has been created

tcp://EMS01:7020> show topic TEST1.TOPIC
 Topic:                 TEST1.TOPIC
 Type:                  static
 Properties:            *prefetch=64,*store=$sys.nonfailsafe
 JNDI Names:            <none>
 Bridges:               queue=APP1.QUEUE selector="JMSCorrelationID='APP1'", 
                        queue=APP2.QUEUE selector="JMSCorrelationID in ('APP2')"

Here JMSCorrelationID is one of the EMS message header property. You need to specify the value when you send the message in queue sender activity. We can configure multiple selectors for the destination like below.

tcp://EMS01:7020> create bridge source=topic:TEST1.TOPIC 
                                target=queue:APP1.QUEUE 
                                selector="JMSCorrelationID in ('ID1','ID2','ID3')"
Bridge has been created

When specifying a bridge, you can specify a particular destination name, or you can use wildcards. For example, if you specify a bridge on topic TEST.* to queue APP.QUEUE, messages delivered to any topic matching TEST.* are sent to APP.QUEUE.

Bridges are not transitive. That is, messages sent to a destination with a bridge are only delivered to the specified bridged destinations and are not delivered across multiple bridges. For example, topic TOPIC1 has a bridge to queue QUEUE. QUEUE has a bridge to topic TOPIC2. Messages delivered to TOPIC1 are also delivered to QUEUE, but not to TOPIC2.

How to delete a bridge?

Syntax : delete bridge source=<type>:<name> target=<type>:<name>

delete bridge source=topic:TEST1.TOPIC target=queue:TEST1.QUEUE
Are you sure (yes,no)? y
Bridge has been deleted

You don’t need to specify the selector details while deleting the bridge.

Let me know your queries and feedback in comments.

Leave a Reply

Your email address will not be published. Required fields are marked *