Discussion:
[rabbitmq-discuss] Consuming multiple messages at a time
Vijay Lakshmi
2013-06-04 17:45:12 UTC
Permalink
Hi,

We have an application where in for each client we create a Queue in
RabbitMQ.
(i.e. we create a binding with client id to a common exchange)
So, all messages that are published with binding key as client id will go
to that queue.

There is only single client which subscribes to this Queue.
The queue will get messages at the rate of 100 msgs/sec for example.

RabbitMQ is sending only 1 message at a time to the consumer. Even if we
set the prefetch count as higher value, the messages are delivered only one
by one.
The callback method in consumer can consume only single message.

void *handleDelivery*(java.lang.String consumerTag,
Envelope
<http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.1.1/rabbitmq-java-client-javadoc-3.1.1/com/rabbitmq/client/Envelope.html>
envelope,
AMQP.BasicProperties
<http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.1.1/rabbitmq-java-client-javadoc-3.1.1/com/rabbitmq/client/AMQP.BasicProperties.html>
properties,
byte[] body)
throws java.io.IOException

Is there a way in RabbitMQ where in we enable RabbitMQ to send mutiple
messages to consumer at a time. In my case there is only one consumer per
queue. So, by sending mutiple messages to consumer at a time will improve
my performance.

Can someone suggest how I can achieve this.
If rabbitMQ does not support, is there any other way of achieving this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130604/8b872944/attachment.htm>
Emile Joubert
2013-06-05 09:10:57 UTC
Permalink
Hi,
Post by Vijay Lakshmi
Is there a way in RabbitMQ where in we enable RabbitMQ to send mutiple
messages to consumer at a time. In my case there is only one consumer
per queue. So, by sending mutiple messages to consumer at a time will
improve my performance.
(I assume by performance you mean throughput and lower overhead rather
than latency.)

You can batch messages by combining multiple logical messages into one
message in the publisher. Consumers will then have to decompose this
message to retrieve individual logical messages. RabbitMQ does not offer
built-in support for this. Bear in mind that the broker deals with
batched rather than the individual component messages for purposes of
message acknowledgement, rejection, TTL, etc.

You should use a message composition/decomposition scheme that makes
sense in your application. Simple concatenation may be sufficient if you
record message boundaries in a header. If messages are in XML format
then you could wrap them in a container element.


-Emile
Emile Joubert
2013-06-05 09:28:53 UTC
Permalink
Post by Vijay Lakshmi
RabbitMQ is sending only 1 message at a time to the consumer. Even if we
set the prefetch count as higher value, the messages are delivered only
one by one.
Actually the broker may be sending multiple messages to the consumer,
even though the consumer only processes one message at a time. If you
set the prefetch-count to a large number then there should be minimal
latency between invocations of handleDelivery().
Robert Raschke
2013-06-05 20:13:34 UTC
Permalink
Isn't this what the prefetch count is all about?
Post by Vijay Lakshmi
Hi,
We have an application where in for each client we create a Queue in
RabbitMQ.
(i.e. we create a binding with client id to a common exchange)
So, all messages that are published with binding key as client id will go
to that queue.
There is only single client which subscribes to this Queue.
The queue will get messages at the rate of 100 msgs/sec for example.
RabbitMQ is sending only 1 message at a time to the consumer. Even if we
set the prefetch count as higher value, the messages are delivered only one
by one.
The callback method in consumer can consume only single message.
void *handleDelivery*(java.lang.String consumerTag,
Envelope <http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.1.1/rabbitmq-java-client-javadoc-3.1.1/com/rabbitmq/client/Envelope.html> envelope,
AMQP.BasicProperties <http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.1.1/rabbitmq-java-client-javadoc-3.1.1/com/rabbitmq/client/AMQP.BasicProperties.html> properties,
byte[] body)
throws java.io.IOException
Is there a way in RabbitMQ where in we enable RabbitMQ to send mutiple
messages to consumer at a time. In my case there is only one consumer per
queue. So, by sending mutiple messages to consumer at a time will improve
my performance.
Can someone suggest how I can achieve this.
If rabbitMQ does not support, is there any other way of achieving this.
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss at lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130605/215fb1a3/attachment.htm>
Loading...