Skip to content

RabbitMQ Inbound

Introduction

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.

Syntax

<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="RabbitMQConsumer" sequence="amqpSeq" onError="amqpErrorSeq" protocol="rabbitmq" suspend="false">
   <parameters>
      <parameter name="sequential">true</parameter>
      <parameter name="coordination">true</parameter>
      <parameter name="rabbitmq.connection.factory">AMQPConnectionFactory</parameter>
      <parameter name="rabbitmq.server.host.name">localhost</parameter>
      <parameter name="rabbitmq.server.port">5672</parameter>
      <parameter name="rabbitmq.server.user.name">guest</parameter>
      <parameter name="rabbitmq.server.password">guest</parameter>
      <parameter name="rabbitmq.queue.name">queue</parameter>
      <parameter name="rabbitmq.exchange.name">exchange</parameter>
      <parameter name="rabbitmq.connection.ssl.enabled">false</parameter>
   </parameters>
</inboundEndpoint>

Properties

Listed below are the properties used for creating a RabbitMQ inbound endpiont.

Required Properties

The following properties are required when creating a RabbitMQ inbound endpiont.

Property Description
sequential The behavior when executing the given sequence.
rabbitmq.connection.factory Name of the connection factory.
rabbitmq.server.host.name Host name of the server.
rabbitmq.server.port The port number of the server.
rabbitmq.server.user.name The user name to connect to the server.
rabbitmq.server.password The password to connect to the server.
rabbitmq.queue.name The queue name to send or consume messages.
rabbitmq.exchange.name The name of the RabbitMQ exchange to which the queue is bound.
coordination This parameter is only applicable in a clustered environment.
In a cluster environment an inbound endpoint will only be executed in worker nodes. If this parameter is set to true in a clustered environment, the inbound will only be executed in a single worker node. Once the running worker node is down, the inbound will start on another available worker node in the cluster. By default, this setting is true.
sequential The behaviour when executing the given sequence.
sequential The behavior when executing the given sequence.
When set as true , mediation will happen within the same thread. When set as false , the mediation engine will use the inbound thread pool. The default thread pool values can be found in the MI_HOME/conf/deployment.toml file, under the `[mediation]` section. The default setting is true.
Suspend If the inbound listener should pause when accepting incoming requests, set this to true. If the inbound listener should not pause when accepting incoming requests, set this to false.

Optional Properties

The following optional properties can be configured when creating an RabbitMQ inbound endpiont.

Property Name Description
rabbitmq.server.virtual.host The virtual host name of the server (if available).
rabbitmq.connection.ssl.enabled Whether to use TCP connection or SSL connection.
rabbitmq.connection.ssl.keystore.location The keystore location.
rabbitmq.connection.ssl.keystore.type The keystore type.
rabbitmq.connection.ssl.keystore.password The keystore password.
rabbitmq.connection.ssl.truststore.location The truststore location.
rabbitmq.connection.ssl.truststore.type The truststore type.
rabbitmq.connection.ssl.truststore.password The truststore password.
rabbitmq.connection.ssl.version The SSL version.
rabbitmq.queue.durable Whether the queue should remain declared even if the broker restarts.
rabbitmq.queue.exclusive Whether the queue should be exclusive or should be consumable by other connections.
rabbitmq.queue.auto.delete Whether to keep the queue even if it is not being consumed anymore.
rabbitmq.queue.auto.ack Whether to send back an acknowledgment.
rabbitmq.queue.routing.key The routing key of the queue.
rabbitmq.queue.delivery.mode The delivery mode of the queue (whether or not the queue is persistent).
rabbitmq.exchange.type The type of the exchange.
rabbitmq.exchange.durable Whether the exchange should remain declared even if the broker restarts.
rabbitmq.exchange.auto.delete Whether to keep the queue even if it is not used anymore.
rabbitmq.factory.heartbeat

The period of time after which the connection should be considered dead.

rabbitmq.message.content.type The content type of the message.

Connection Recovery Properties

In case of a network failure or broker shutdown, the Micro Integrator can try to recreate the connection.

If you want to enable connection recovery, you should configure the following parameters in the inbound endpoint:

<parameter name="rabbitmq.connection.retry.interval" locked="false">10000</parameter>
<parameter name="rabbitmq.connection.retry.count" locked="false">5</parameter>   

If the parameters are configured with sample values as given above, the server makes 5 retry attempts with a time interval of 10000 miliseconds between each retry attempt to reconnect when the connection is lost. If reconnecting fails after 5 retry attempts, the Micro Integrator terminates the connection.

In addition to the above parameters, if you want to set the interval between retry attempts with which the RabbitMQ client should try reconnecting to the Micro Integrator, you can configure the following parameter:

<parameter name="rabbitmq.server.retry.interval" locked="false">10000</parameter>

Setting the value of rabbitmq.server.retry.interval to be less than the value of rabbitmq.connection.retry.interval helps synchronize the reconnection of the Micro Integrator and the RabbitMQ client.

Top