jms egress connector

JMS Egress Connector

Version: 17.07

Supported Since: 17.01

What is Spring JMS Egress Connector?

Spring JMS Egress Connector can be used to send messages to JMS destinations from UltraESB. At the moment, UltraESB supports JMS specification 1.0.2+ and if you are using any proprietary JMS server it MUST be compatible with the 1.0.2+ specification.

In order to use the JMS Egress Connector, you must first select the Spring JMS Connector dependency from the connector list when you are creating an empty Ultra project. If you have already created a project, you can add the Spring JMS Connector dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list, select the Spring JMS Connector dependency.
jms egress connector 13

Out Ports

On Exception

The message will be sent to this out port if the Egress Connector failed to process the message due to some reason

Response Processor

The message will be sent to this out port if the Complete Flow property is disabled and the message has been sent to the JMS destination successfully

Side Ports

Connector Operation

This port is used to connect operational elements to the Egress Connector. By-default, user does not have to connect any operational element and the default connector operation will be used.

Parameters

* marked fields are mandatory

JMS Template *

Basic

The org.springframework.jms.core.JmsTemplate instance to be used in-order to send messages to destination queue.

JMS Destination *

Basic

Name of the destination queue

Meta-Info Populator

Advanced

An instance of org.adroitlogic.x.transport.jms.util.MetaInfoPopulator to allow custom meta information to be populated into the message

Complete Flow

Advanced

If true, the integration flow will be completed once the message has been sent to the JMS destination. If false, the original message sent to the JMS destination will be emitted to the Response Processor out port to continue the flow

Weight

Fail-Over

Weight for the Egress Connector if Egress Load Balancer element is used with Weighted/Weighted with Failover algorithm is used.

Sample Use Case

Prerequisite

You need to specify a JMS Template to send messages to the destination. For this example let’s use ActiveMQ and if you have not already installed ActiveMQ please follow the installation guide.

First open the project.xpml file of the project and right click on it (on the XML content of the file). From the context menu, select Resource Template as shown in below figure

jms egress connector 5

After that from the shown dialog box, select ActiveMQ JMS template.

jms egress connector 6

Next you need to specify the required parameters as shown below. It is mandatory to specify a bean prefix and for that you can specify any value. The only other mandatory field is the ActiveMQ Broker URL.

jms egress connector 7
1. Sending a message to a JMS queue

In-order to send a message to a destination queue, first we need to inject a message to the UltraESB and for that let’s first add a JMS Ingress Connector to obtain a message into the UltraESB. If you are not familiar with JMS Ingress Connector, refer JMS Ingress Connector.

Next add a JMS Egress Connector and specify the Active MQ JMS Template and the destination queue name as shown below

jms egress connector 1

After that connect JMS Ingress/Egress connectors as shown below.

jms egress connector 2

Further, from the Response Processor out port of the JMS Egress connector, you can obtain the original message you have send to the JMS destination ONLY if the message sent was successful so that you can continue the flow, but if you want to complete the integration flow, as in this example, you can do it without connecting any processing element to the Response Processor out port.

Go to the Advanced Tab of the JMS Egress Connector configuration and select the flow complete switch as below. This will complete the integration flow once the message has been sent to the JMS destination

jms egress connector 8

Now after creating a run configuration and running the project, you will be able to see that the message has been obtained from the remote JMS queue and sent it to the destination queue.

2. Sending a message to a JMS queue transactionally

In this example let’s see how we can send a message obtained from a remote JMS queue can be sent to multiple destination queues as an atomic operation through a transaction. First create the flow as shown below

jms egress connector 3

As you can see, there is one JMS Ingress Connector with a transaction manager specified (under Transaction tab in the property pane) and within the transaction scope there are two JMS Egress Connectors to send the message to two destination queues. After sending the message to both queues, we are closing the transaction scope and completing the integration flow with a Successful Flow End component. If you run the project, you can see that the original message has been sent to both destination queues.

Now if we add an Exceptional Flow End element after the second JMS Egress Connector, you can see that message flow completes with an exception while the transaction scope is still active. In this case, the original message is not sent to the either of destination queues and rolled back to the source queue.

jms egress connector 4

This happens because when we specify the transaction manager to the JMS Ingress Connector and include the Egress Connectors within the same transaction scope, all JMS queueing/de-queuing operations are bounded with a singe transaction and if the message flow fails within the transaction scope (since the transaction scope is not closed), the transaction will be rolled back.

It should be noted that for a for the JMS Ingress/Egress connectors to be bound by a single transaction, the JMS template MUST use the same JMS Connection Factory used by the Ingress Connector

Now suppose you are getting a message from a non-transactional transport like HTTP. As shown in the below image, even in this case we can sent the message to multiple destination JMS queues in a single transaction.

jms egress connector 9

Although, in here you need to specify the transaction manager in the TransactionScopeStartElement as shown below.

jms egress connector 10

Now if you modify the flow as below and run the project again, you can see that the message has not been sent to either of the JMS destinations.

jms egress connector 11
When you specify a transaction manager to the Spring JMS Ingress Connector, it is given the highest priority and the transaction manager specified in the TransactionScopeStartElement is ignored. But once you include a TransactionScopeEndElement and finish the transaction started by the transaction manager of the JMS Ingress Connector, for all the subsequent transaction scopes, the transaction manager specified in the TransactionScopeStartElement will be used.
jms egress connector 12

As an example in the above flow, the same transaction manager is specified for JMS Ingress Connector, TransactionScopeStartElement and TransactionScopeEndElement. If any exception occurs within the transaction scope (A), the message will be rolled back to the original source queue and message will not be sent to any of the destination queues.

If any exception occurs within the transaction scope (B), then the message will be sent to the destination X, Y, but the message will not be sent to either of destinations P, Q.

In this topic
In this topic
Contact Us