Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Competing Consumers

I want to configure a spring integration application so that if I put a number of tasks, each represented by one message, on a channel then one of a group of endpoints will pick the next task and process it. This would entail some thread pool executor service I guess.

like image 342
Paul McKenzie Avatar asked Mar 01 '11 17:03

Paul McKenzie


People also ask

What is Competing consumers?

Competing Consumers are multiple consumers that are all created to receive messages from a single Point-to-Point Channel. When the channel delivers a message, any of the consumers could potentially receive it.

What is a consumer RabbitMQ?

Messaging protocols supported by RabbitMQ use both terms but RabbitMQ documentation tends to prefer the latter. In this sense a consumer is a subscription for message delivery that has to be registered before deliveries begin and can be cancelled by the application.


1 Answers

Yes, use a dispatcher + task executor with the channel (aka ExecutorChannel). That way any endpoint (e.g. service-activator) consuming from the channel will be invoked asynchronously using dispatcher's thread pool.

In the following example, any messages landing on channel channel01 will be consumed by the jobLauncher service within one of the taskExecutor threads.

<int:channel id="channel01">
    <int:dispatcher task-executor="taskExecutor">
</int:channel>

<task:executor id="taskExecutor" pool-size="2"/>

<int:service-activator input-channel="channel01" ref="jobLauncher">
like image 106
Sab Than Avatar answered Sep 30 '22 01:09

Sab Than