[rabbitmq-discuss] can I create multiple channel for multiple thread work?

1,140 views
Skip to first unread message

sam_mis

unread,
Mar 4, 2011, 12:51:02 AM3/4/11
to rabbitmq...@lists.rabbitmq.com

Hi All

I have a problem/doubt with a rabbit queue .i used only one AMQP connection
and create the no. channels in respect to no. of thread.I need that 25
threads consume one rabbit queue.my publisher can put message onto the queue
and my thread consumer are listen the queue and do some processing on
message and again publish the process message into another queue,after
completion the above process he acknowledge.also i am using the
channel.basicQos(1), one thread can get only one message until it
not acknowledge.
it is correct way to do that?
--
View this message in context: http://old.nabble.com/can-I-create-multiple-channel-for-multiple-thread-work--tp31065140p31065140.html
Sent from the RabbitMQ mailing list archive at Nabble.com.

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq...@lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Rob Harrop

unread,
Mar 4, 2011, 6:35:25 AM3/4/11
to rabbitmq...@lists.rabbitmq.com
Creating a single connection and having ~25 channels will be perfectly
fine.

I recommend using QueueingConsumer for each of the consumers on these
channels to prevent any possible deadlock problems.

Setting channel.basicQos(1) will mean that your consumers get
approximately fair distribution of the work, but you should ensure that
you are using autoAck=false when setting up the consumer otherwise QoS
settings are ignored.

Rob

On 04/03/11 05:51, sam_mis wrote:
> Hi All
>
> I have a problem/doubt with a rabbit queue .i used only one AMQP connection
> and create the no. channels in respect to no. of thread.I need that 25
> threads consume one rabbit queue.my publisher can put message onto the queue
> and my thread consumer are listen the queue and do some processing on
> message and again publish the process message into another queue,after
> completion the above process he acknowledge.also i am using the
> channel.basicQos(1), one thread can get only one message until it
> not acknowledge.
> it is correct way to do that?

_______________________________________________

sam_mis

unread,
Mar 4, 2011, 7:25:15 AM3/4/11
to rabbitmq...@lists.rabbitmq.com

I have some doubt when the threads are reading messages from a queue.i want
to make it sure that one message is will be read by only one thread not
twice again.Is it required some other configuration ?

Thanks

--
View this message in context: http://old.nabble.com/can-I-create-multiple-channel-for-multiple-thread-work--tp31065140p31067190.html


Sent from the RabbitMQ mailing list archive at Nabble.com.

_______________________________________________

Gavin M. Roy

unread,
Mar 4, 2011, 7:33:05 AM3/4/11
to sam_mis, rabbitmq...@lists.rabbitmq.com
What client library are you using?

sam_mis

unread,
Mar 6, 2011, 10:39:59 PM3/6/11
to rabbitmq...@lists.rabbitmq.com

I am using rabbitmq-java-client-2.0.0.

--
View this message in context: http://old.nabble.com/can-I-create-multiple-channel-for-multiple-thread-work--tp31065140p31084682.html

Rob Harrop

unread,
Mar 7, 2011, 11:57:46 AM3/7/11
to sam_mis, rabbitmq...@lists.rabbitmq.com
If all the consumers are attached to the same queue then only one of them will see a given message from that queue.

The number of threads involved has no bearing on this. If you are seeing unexpected behaviour you should check that multiple copies of a message are not finding their way into the queue. Also, you should try upgrading to the latest Java client.

Regards,

Rob
Reply all
Reply to author
Forward
0 new messages