amqp egress connector

AMQP Egress Connector

Version: 17.01

Supported Since: 17.01

What is AMQP Egress Connector?

AMQP Egress connector can be used to send messages to AMQP destinations from the UltraESB. When using AMQP Egress Connector you can use it with a transactional AMQP Ingress Connector or with a CallbackHandler

You can either use transactional (transaction mode) or Callback Handler (confirm mode) with a specified Connection Factory

Sample Use Case

Prerequisite

In order to use the AMQP Egress Connector you must first select the "AMQP 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 "AMQP Connector" dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list, select the "AMQP Connector" dependency.

After that you need to specify a Connection Factory to connect to the AMQP Server. For this example let’s use Rabbit MQ and if you have not already installed Rabbit MQ, please follow the Installation Guide

1. Sending a message to an AMQP queue in transaction mode

In-order to use the transaction mode, you must first add the required resources in the project.xpml file. In the design view of the project.xpml file, under the "Custom Template" dropdown menu, select the "RabbitMQ with Transactions" item and fill the required properties in the pop-up modal and save it.

After that you will be able to see the required resources are added to the project.xpml file as shown below

amqp egress connector 1

After that, 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 AMQP Ingress Connector to obtain a message into the UltraESB. If you are not familiar with AMQP Ingress Connector, refer AMQP Ingress Connector.

Then, You need to specify the “rabbitMQ-UltraTxnManager” as the transaction manager and enable Channel transacted in the Ingress Connector apart from specifying the connection factory and source queue name.

After that, add a transaction scope and connect it to a Logger processing element to log the payload of the received message. Next add an AMQP Egress Connector and specify the Rabbit MQ Template and the destination queue name as shown below for the Egress Connector.

amqp egress connector 2

The full integration flow should be as shown below

amqp egress connector 3

Now after creating a run configuration [link to 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 and the payload is logged into the console as well.

Next, let’s add a Clone Message Processor and a "Exceptional Flow End" element as show below. Specify Keep Original as the "Exchange Pattern" and On Completion of Both as the "Completion Procedure" properties of the Clone Message Processor. Now the flow should look as below

amqp egress connector 4

Now if you run the project, you can see that the message does not get delivered to the destination queue even though the payload has been logged in the console. This happens because the message flow within the transaction scope fails since we are ending the flow by throwing an exception. Hence, the transaction will be rolledback and the message will be available on the original source queue for re-delivery.

It should be noted that for a for the AMQP Ingress/Egress connectors to be bound by a single transaction, the AMQP template MUST use the same AMQP Connection Factory used by the Ingress Connector
2. Sending a message to an AMQP queue in confirmation mode

When using the confirmation mode, you need to add a callback handler. In the project.xpml file in Design view select "RabbitMQ with Callback" from the "Custom Template" drop down menu. Specify the required properties and save the pop-up modal. Now you can see that the required resources are added as shown below

amqp egress connector 5

Now let’s create a simple flow as shown below

amqp egress connector 6
In the above flow you should only specify the connection factory and the source queue name in the AMQP Ingress Connector. As for the Egress Connector, specify the AMQP template and a non-existing queue name so that the rabbit server exchange will fail to route the message to a destination queue. Further, under the Advanced category of the Egress Connector, select the confirmReturn Callback Handler

Now if you run this flow and send a message you will see an error message similar to below one

ERROR RabbitConfirmAndReturnCallback Returned message  with reply code 312 and reply test NO_ROUTE from exchange '' with routing key 'nonQueue'

This means that the rabbit server has failed to find the destination queue and the message delivery has failed which results in a message flow failure.

Out Ports

On Exception

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

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

AMQP Template *

Basic

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

Destination *

Basic

Name of the destination queue

Callback Handler

Advanced

Callback object to be invoked when async response received from the MQ server when a message is sent notifying its received status by the server. Users can specify their custom implementations of org.adroitlogic.x.base.trp.SendCallback class as the Callback Handler as well.

Weight

Fail-Over

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

In this topic
In this topic
Contact Us