Katlock
Katlock

Reputation: 1386

Mule ESB multi-thread consumers from RabbitMQ Queue

In my MuleESB app config I have a RabbitMQ Queue and I want to consume messages using multi-threading where order does not matter.

I have the following configuration:

<amqp:connector name="RabbitMQMultiThread"  validateConnections="true" host="${rabbitmq_host}" port="${rabbitmq_port}" fallbackAddresses="${rabbitmq_fallback_addresses}" virtualHost="${rabbitmq_virtual_host}" username="${rabbitmq_username}" password="${rabbitmq_password}" ackMode="AMQP_AUTO" doc:name="AMQP Connector">
       <reconnect-forever frequency="30000"/>           
    </amqp:connector>

And I want to use that AMQP connector config in my flow as following:

<flow name="mule-flow">
 <amqp:inbound-endpoint connector-ref="RabbitMQMultiThread" responseTimeout="10000" exchange-pattern="request-response" doc:name="AMQP-0-9" queueName="myqueue"/>
        <logger message="got message" level="INFO" category="mycategory" doc:name="Logger"/> 
  <component doc:name="myPojo">
        <spring-object bean="myPojo"/>
    </component>             
 </flow>

Is it possible to consume messages from a RabbitMQ using multi-threading in Mule using the flow config I have?

Upvotes: 0

Views: 263

Answers (1)

utechtzs
utechtzs

Reputation: 1023

Yes, Mule does this automatically. Reference: https://docs.mulesoft.com/mule-runtime/3.8/flow-processing-strategies#implicit-processing-strategies

We had to retain the order of messages, so we set the flow to synchronous and set numChannels and prefetch to 1.

<amqp:connector name="AMQP_Connector" validateConnections="true" host="${amqp.host}" port="${amqp.port}" username="${amqp.user}" password="${amqp.password}" numberOfChannels="1" prefetchCount="1" doc:name="AMQP-0-9 Connector" virtualHost="${amqp.virtualHost}">

Upvotes: 0

Related Questions