Skip to content

RabbitMQ Mule Connector

Regunath B edited this page Aug 23, 2013 · 11 revisions

The "mule-transport-rabbitmq" Maven project under Trooper is a Rabbit MQ Mule Connector/Transport. It is suitable for use with Mule 2.x installations and RabbitMQ 2.x Java client.

Key features of this transport are:

  • Interface compliance with the Mule connector API and is therefore a drop-in implementation for Mule deployments with no external dependencies to Trooper or any other 3rd party libraries.
  • Supports re-connect to RabbitMQ if the Broker goes down and is brought up again.
  • Supports Sync and Async Mule end-point definitions.
  • Configurability for: Durability, Message commit counts and Keep Alive
  • Ability to defer message consumption until the entire Mule Context is loaded : helps clean,controlled application startup.
  • Support for dead-lettering messages that fail to process, even after a re-queue. Declarative on Mule endpoint definitions.
  • Support RabbitMQ cluster configuration for the connector. Reconnect/Retries are attempted for any available member of the cluster.

Maven artifact

This Maven artifact uses a naming convention that is consistent with other Mule transports. The naming is therefore devoid of any Trooper name elements.

GroupID/Org ArtifactID/Name Version
org.mule.transports mule-transport-rabbitmq 2.2.3

Building the transport

  • git clone Trooper
  • cd to mule-transport-rabbitmq
  • run "mvn clean install"

Configuration Snippets

Sample Mule configurations are explained here:

Declaring a RabbitMQ Mule connector

<rabbitmq:connector name="LocalhostRabbitMQConnector">
    <spring:property name="rabbitMQConfigurations">
        <spring:list>
	    <spring:bean class="org.trpr.mule.transport.rabbitmq.RabbitMQConfiguration" id="queueConfiguration1">
  	        <spring:property name="userName" value="guest" />
	        <spring:property name="password" value="guest" />
	        <spring:property name="hostName" value="localhost" />
	        <spring:property name="virtualHost" value="/" />
	        <spring:property name="portNumber" value="5672" />
	    </spring:bean>
	    <spring:bean class="org.trpr.mule.transport.rabbitmq.RabbitMQConfiguration" id="queueConfiguration2">
  	        <spring:property name="userName" value="guest" />
	        <spring:property name="password" value="guest" />
	        <spring:property name="hostName" value="localhost" />
	        <spring:property name="virtualHost" value="/" />
	        <spring:property name="portNumber" value="5673" />
             </spring:bean>
	</spring:list>
    </spring:property>    
    <spring:property name="retryPolicyTemplate">
        <spring:bean
            class="org.mule.modules.common.retry.policies.ExhaustingRetryPolicyTemplate">
            <spring:property name="sleepTime" value="2000" />
            <spring:property name="retryLimit" value="100" />
        </spring:bean>
    </spring:property>
</rabbitmq:connector>

The following additional Spring properties are supported on this connector:

    <spring:property name="durableMessageCommitCount" value="10" />
    <spring:property name="prefetchCount" value="1" />
    <spring:property name="requestHeartBeat" value="30" />

Declaring end-points

  • Queue based end-point
<endpoint connector-ref="LocalhostRabbitMQConnector" name="GreetingInputEndpoint" address="amqp://myexchange:direct/?queue=greetingInput"/>
  • Durable queue based end-point:
<endpoint connector-ref="LocalhostRabbitMQConnector" name="GreetingInputEndpoint" address="amqp://myexchange:direct/?queue=greetingInput&amp;durable=true"/>
  • Durable queue based end-point with support for re-queue and dead-lettering:
<endpoint connector-ref="LocalhostRabbitMQConnector" name="GreetingInputEndpoint" address="amqp://myexchange:direct/?queue=greetingInput&amp;durable=true&amp;message-requeued=true&amp;dead-lettered=true"/>

Features not (yet) supported or tested

  • Ability to participate in Mule transactions
  • One-off message requesting from queue using the transport