[rabbitmq-discuss] Concurrently execution of jobs - Spring AMQP with RabbitMQ

jhiemer jvhiemer at googlemail.com
Mon Jan 9 12:58:21 GMT 2012


Hi,
I finally solved my issue with the help of Spring. In Spring AMQP
there is an option for the definition of consumers being started when
creating a SimpleMessageListenerContainer. A successful configuration
looks like this:

public SimpleMessageListenerContainer compositionListenerContainer() {
		SimpleMessageListenerContainer container = new
SimpleMessageListenerContainer(connectionFactory());
		container.setQueues(compositionQueue());
		container.setMessageListener(compositionMessageListenerAdapter());
		container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
		container.setPrefetchCount(prefetchCount);
		container.setErrorHandler(errorHandler());
		container.setConcurrentConsumers(concurrentConsumers);
		return container;
}

Have a nice day.

On Jan 9, 12:25 pm, jhiemer <jvhie... at googlemail.com> wrote:
> Hi,
> I have a basic question regarding the design of an application. The
> scenario is as follows. A frontend sends job message to two different
> queues (respectively routingKeys). The following shows the
> configuration of the queues.
>
> amqp.schedule.routingKeyName=service.schedule
> amqp.schedule.routingKey=service.schedule
> amqp.schedule.queue=service.schedule
> amqp.schedule.max=10
>
> amqp.compose.routingKeyName=service.compose
> amqp.compose.routingKey=service.compose
> amqp.compose.queue=service.compose
> amqp.compose.max=2
>
> While scheduling does not take that much time, compose jobs may take
> between 1 and 10 minutes. As you can see I can run 10 schedule jobs
> concurrently, while I can only run 2 compose jobs concurrently. I am
> using Spring AMQP with RabbitMQ.
>
> To limit this, do I need to run for compose 2 consumers, and for
> schedule 10?
>
> P.S. In Spring AMQP there is ChannelAwareMessageListener, which fires
> asynchronous the onMessage() method, whenever a message arrives,
> opening a thread for each message. Would that be the other way to go?
> What would I need to take care of in this case? What I was thinking of
> was two Consumers (Compose, Schedule) with prefetchCount set to 2
> (Compose) or 10 (Schedule) to limit the concurrent execution of tasks?
>
> I would be glad if anyone could help me out. I am bit stuck at the
> moment. :-(
>
> Regards
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list