Java Client - Channel.basicGet with Timeout

343 views
Skip to first unread message

Martin Gejer

unread,
Jan 15, 2015, 1:22:34 PM1/15/15
to rabbitm...@googlegroups.com
Good evening. I was wondering if i could get help with the Java client for rabbit. 

I'm trying to use the QueueingConsumer and QueueingConsumer.Delivery from the Hello World tutorial (http://www.rabbitmq.com/tutorials/tutorial-one-java.html) but I'm having the problem that it retrieves all the items in the queue. Is there a way to tell the consumer to remove only one element from the queue per "basicConsume" call?

I also tried to use the method "basicGet" from the channel (http://www.rabbitmq.com/javadoc/com/rabbitmq/client/Channel.html#basicGet(java.lang.String, boolean)). Works correctly, but I haven't been able to config a timeout for it. If the queue turns out to be empty, the method will return "null" immediately, instead I would like to make him wait a certain period of time.

I hope I made myself clear, sorry for the bad english.

Thanks in advanced.

Michael Klishin

unread,
Jan 15, 2015, 1:24:56 PM1/15/15
to rabbitm...@googlegroups.com, Martin Gejer
On 15 January 2015 at 21:22:36, Martin Gejer (mgej...@gmail.com) wrote:
> I'm trying to use the QueueingConsumer and QueueingConsumer.Delivery
> from the Hello World tutorial (http://www.rabbitmq.com/tutorials/tutorial-one-java.html)
> but I'm having the problem that it retrieves all the items in the
> queue. Is there a way to tell the consumer to remove only one element
> from the queue per "basicConsume" call?
>
>
> I also tried to use the method "basicGet" from the channel (http://www.rabbitmq.com/javadoc/com/rabbitmq/client/Channel.html#basicGet(java.lang.String,
> boolean)(http://www.rabbitmq.com/javadoc/com/rabbitmq/client/Channel.html#basicGet(java.lang.String,%20boolean))).
> Works correctly, but I haven't been able to config a timeout for
> it. If the queue turns out to be empty, the method will return "null"
> immediately, instead I would like to make him wait a certain period
> of time.
>
> I hope I made myself clear, sorry for the bad english.

Yes, there is. See Tutorial 2. 
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Martin Gejer

unread,
Jan 15, 2015, 2:15:47 PM1/15/15
to rabbitm...@googlegroups.com, mgej...@gmail.com
Excelent! thanks!

RAHUL AGRAWAL

unread,
Apr 8, 2017, 10:26:56 AM4/8/17
to rabbitmq-users, mgej...@gmail.com
I am also facing similar kind of issue. What is this tutorial 2 link.

Michael Klishin

unread,
Apr 8, 2017, 11:37:01 AM4/8/17
to rabbitm...@googlegroups.com, mgej...@gmail.com
https://google.com is a good place to start for a software professional.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Staff Software Engineer, Pivotal/RabbitMQ
Reply all
Reply to author
Forward
0 new messages