RabbitMQ AMQP Transport

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

RabbitMQ AMQP Transport

AMQP is a wire-level messaging protocol that describes the format of the data that is sent across the network. If a system or application can read and write AMQP, it can exchange messages with any other system or application that understands AMQP, regardless of the implementation language.

The RabbitMQ AMQP transport is implemented using the RabbitMQ Java Client. It allows you to send or receive AMQP messages by calling an AMQP broker (RabbitMQ) directly, without the need to use different transport mechanisms, such as JMS. 

The following diagram illustrates a scenario where the WSO2 Enterprise Integrator(WSO2 EI) uses the RabbitMQ AMQP transport to exchange messages between RabbitMQ Java Clients by calling RabbitMQ brokers.


As you can see in the diagram, the Sender uses the RabbitMQ Java Client to publish messages to an AMQP queue (Q1), and the Receiver users it to consume messages from an AMQP queue (Q2). In this scenario, a proxy service in the WSO2 EI listens to Q1, and when a message becomes available on the queue, the proxy service consumes it and publishes it to Q2.

This section provides information on configuring the RabbitMQ transport in WSO2 EI along with information on how to enable connection recovery, how to enable SSL support as well as a sample RabbitMQ proxy service to describe how to use the RabbitMQ transport.



Configuring the RabbitMQ AMQP transport

  1. Open <EI_HOME>/conf/axis2/axis2.xml for editing.

  2. In the transport listeners section, add the following RabbitMQ transport listener, replacing the values with your host, port, username, and password to connect to the AMQP broker. 

    <transportReceiver name="rabbitmq" class="org.apache.axis2.transport.rabbitmq.RabbitMQListener"> <parameter name="AMQPConnectionFactory" locked="false"> <parameter name="rabbitmq.server.host.name" locked="false">192.168.0.3</parameter> <parameter name="rabbitmq.server.port" locked="false">5672</parameter> <parameter name="rabbitmq.server.user.name" locked="false">user</parameter> <parameter name="rabbitmq.server.password" locked="false">abc123</parameter> </parameter> </transportReceiver>

    As an optional step, you can create multiple connection factories if you want this listener to connect to multiple brokers.

  3. In the transport senders section, add the following RabbitMQ transport sender, which will be used for sending AMQP messages to a queue:

    <transportSender name="rabbitmq" class="org.apache.axis2.transport.rabbitmq.RabbitMQSender"/>
  4. Start WSO2 EI.

RabbitMQ AMQP transport parameters

Following are details on the listener parameters you can set:

Parameter

Description

Required

Parameter

Description

Required

rabbitmq.connection.factory

The name of the connection factory.

Yes

rabbitmq.exchange.name

Name of the RabbitMQ exchange to which the queue is bound. Use this parameter instead of rabbitmq.queue.routing.key, if you need to use the default exchange and publish to a queue.

No

rabbitmq.queue.name

The queue name to send or consume messages. If you do not specify this parameter, you need to specify the rabbitmq.queue.routing.key parameter.

Yes

rabbitmq.queue.auto.ack

Defines how the message processor sends the acknowledgement when consuming messages recived from the RabbitMQ message store. If you set this to true, the message processor automatically sends the acknowledgement to the messages store as soon as it receives messages from it. This is called an auto acknowledgement.

If you set it to false, the message processor waits until it receives the response from the backend to send the acknowledgement to the mssage store. This is called a client acknowledgement.

No

rabbitmq.consumer.tag

The client­ generated consumer tag to establish context.

No

rabbitmq.channel.consumer.qos

The consumer qos value. You need to specify this parameter only if the rabbitmq.queue.auto.ack parameter is set to false.

No

rabbitmq.queue.durable

Whether the queue should remain declared even if the broker restarts.

 No

rabbitmq.queue.exclusive

Whether the queue should be exclusive or should be consumable by other connections.

 No

rabbitmq.queue.auto.delete

Whether to keep the queue even if it is not being consumed anymore.

 No

rabbitmq.queue.routing.key

The routing key of the queue.

 No

rabbitmq.exchange.type

The type of the exchange.

 No

rabbitmq.exchange.durable

Whether the exchange should remain declared even if the broker restarts.

 No

rabbitmq.exchange.auto.delete

Whether to keep the exchange even if it is not bound to any queue anymore.

 No

rabbitmq.message.content.type

The content type of the consumer.

Note

If the content type is specified in the message, this parameter does not override the specified content type.

 No. The default value is text/xml.

rabbitmq.queue.autodeclare

Whether to create queues if they are not present. However, you should set this parameter only if queues are not declared prior on the broker. Setting this parameter in the publish URL to false improves RabbitMQ transport performance.

No

rabbitmq.exchange.autodeclare

Whether to create exchanges if they are not present. However, you should set this parameter only if exchanges are not declared prior on the broker. Setting this parameter in the publish URL to false improves RabbitMQ transport performance.

No



Following are details on the sender parameters you can set:

Parameter

Description

Required

Parameter

Description

Required

rabbitmq.server.host.name

Host name of the server.

Yes

rabbitmq.server.port

Port number of the server.

Yes

rabbitmq.exchange.name

The name of the RabbitMQ exchange to which the queue is bound. Use this parameter instead of rabbitmq.queue.routing.key, if you need to use the default exchange and publish to a queue.

No

rabbitmq.queue.routing.key

The exchange and queue binding key that will be used to route messages.

No

rabbitmq.replyto.name

The name of the call back­ queue. Specify this parameter if you expect a response.

No

rabbitmq.queue.delivery.mode

The delivery mode of the queue. Possible values are 1 and 2.
1 - Non­-persistent.
2 - Persistent. This is the default value.

No

rabbitmq.exchange.type

The type of the exchange.

No

rabbitmq.queue.name

The queue name to send or consume messages. If you do not specify this parameter, you need to specify the rabbitmq.queue.routing.key parameter.

Yes

rabbitmq.queue.durable

Whether the queue should remain declared even if the broker restarts. The default value is false.

No

rabbitmq.queue.exclusive

Whether the queue should be exclusive or should be consumable by other connections. The default value is false

No

rabbitmq.queue.auto.delete

Whether to keep the queue even if it is not being consumed anymore. The default value is false.

No

rabbitmq.exchange.durable

Whether the exchange should remain declared even if the broker restarts.

No

rabbitmq.queue.autodeclare

Whether to create queues if they are not present. However, you should set this parameter only if queues are not declared prior on the broker. Setting this parameter in the publish URL to false improves RabbitMQ transport performance.

No

rabbitmq.exchange.autodeclare

Whether to create exchanges if they are not present. However, you should set this parameter only if exchanges are not declared prior on the broker. Setting this parameter in the publish URL to false improves RabbitMQ transport performance.

No