consumer-timeout not working. What am I doing wrong?

2,428 views
Skip to first unread message

Josh Holdaway

unread,
May 16, 2023, 9:45:25 AM5/16/23
to rabbitmq-users
Hello,

I've modified the c# tutorial sample to include the following:
channel.QueueDeclare(queue: "task_queue",
 durable: true,
 exclusive: false,
 autoDelete: false,
 arguments: new Dictionary<string, object>() { { "x-consumer-timeout", 10000 } });

Notice I added the x-consumer-timeout.  It seems to be not doing anything?  I'm expecting after 10 seconds if I don't acknowledge, it would give the message to another consumer.

What am I doing wrong?

Michal Kuratczyk

unread,
May 16, 2023, 10:28:58 AM5/16/23
to rabbitm...@googlegroups.com
It was added in 3.11.15, just 2 weeks ago. Are you running the latest version?

--
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 view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/6d2c6595-edfa-4b17-84da-7e31c819aab3n%40googlegroups.com.


--
Michał
RabbitMQ team

Josh Holdaway

unread,
May 16, 2023, 10:52:39 AM5/16/23
to rabbitmq-users
Is this correct in the docker compose?
  rabbit:
    image: "rabbitmq:3-management"

Michal Kuratczyk

unread,
May 16, 2023, 11:03:29 AM5/16/23
to rabbitm...@googlegroups.com
Yes, if you actually pull it. If you pulled from this tag before, you may be using a cached image. 

--
Michał

Josh Holdaway

unread,
May 16, 2023, 12:08:56 PM5/16/23
to rabbitmq-users
It says 3.11.15 in the management console.

Michal Kuratczyk

unread,
May 16, 2023, 12:53:34 PM5/16/23
to rabbitm...@googlegroups.com
Well, maybe there's a bug or misunderstanding in how it works. Please provide a test case - a script or a series of commands we can run to see the problem.

Best,



--
Michał
RabbitMQ team

Josh Holdaway

unread,
May 16, 2023, 3:43:18 PM5/16/23
to rabbitmq-users
Hello,

I've just modified the sample code here: https://www.rabbitmq.com/tutorials/tutorial-two-dotnet.html
I just changed the code for the queuedeclare to include the arguement:
channel.QueueDeclare(queue: "task_queue",
 durable: true,
 exclusive: false,
 autoDelete: false,
 arguments: new Dictionary<string, object>() { { "x-consumer-timeout", 10000 } });

In the worker I changed the Thread.Sleep to Thread.Sleep(20000);
To test, I start 2 workers up, and 1 producer.  I send 1 message, and the first worker grabs it, and waits the 20 seconds, but what I'm expecting is after 10seconds the message is given to the 2nd worker as the first worker didn't call the channel.BasicAck in that 10 seconds.

Hope that helps.  Thank you so much!

Michal Kuratczyk

unread,
May 17, 2023, 6:23:41 AM5/17/23
to rabbitm...@googlegroups.com
In the future, please try to provide something we can just execute. We had at least a few issue reports a day and
putting together the reproduction steps is really time consuming. The more we do that, the less time we have
for RabbitMQ development.

This is a test case I put together:

# publish a single message
perf-test -ad false -f persistent -qa x-queue-version=2,x-consumer-timeout=300000 -u q5m -y 0 -C 1

# start a consumer with very high latency
date; perf-test -ad false -f persistent -qa x-queue-version=2,x-consumer-timeout=300000 -u q5m -x 0 -D 1 -L 1000000000;date

# start another consumer that should get the message after the high-latency consumers times out
date; perf-test -ad false -f persistent -qa x-queue-version=2,x-consumer-timeout=300000 -u q5m -x 0 -D 1; date

It works, but it seems to be taking 1 minute longer to time out than expected (6 instead of 5, 11 instead of 10, when I used 600000).
This one extra minute seems to be a bug that I don't fully understand. However, this feature was never meant to be used with such low values.
The default is 30 minutes and people keep asking how to extend it, which is why this per-queue/per-consumer option was added.
While the extra minute seems to be a bug, the timeout is also not meant to be precise. So we might fix it, but please don't expect
that whatever you set will be enforced down to the second. The consumer timeout is a mechanism to make sure we can make progress
even if a consumer stopped responding, not to guarantee delivery in a certain time.

Best,



--
Michał
RabbitMQ team

Josh Holdaway

unread,
May 17, 2023, 6:35:57 PM5/17/23
to rabbitmq-users
Hello and thank you for the response.

I forked the dotnet samples and made the changes here:
(Timeout set to 5 minutes, with the worker set to sleep for 10 minutes)

1. Run the NewTask project once to add a message
2. Run 2 instances of the worker project.

See the screenshot below of the worker instances, you will see the 2nd worker doesn't get message after the 5 minute timeout.  

rabbitmqworker.png

What am I doing wrong?  

Thanks!

Josh

Michal Kuratczyk

unread,
May 18, 2023, 8:04:35 AM5/18/23
to rabbitm...@googlegroups.com
Seems to be working for me (with the 1 extra minute caveat I created an issue for: https://github.com/rabbitmq/rabbitmq-server/issues/8221).
The second consumer received the messages 6 minutes after the first one.

> dotnet run
[*] Waiting for messages.
Press [enter] to exit.
[x] Received Hello World! on 5/18/2023 10:12:18 AM                                                                                                                                                                        [x] Done on 5/18/2023 10:22:18 AM

> date; dotnet run
Thu May 18 10:12:25 CEST 2023
[*] Waiting for messages.
Press [enter] to exit.                                                                                                                                                                                                                          [x] Received Hello World! on 5/18/2023 10:18:18 AM
[x] Done on 5/18/2023 10:28:18 AM




--
Michał
RabbitMQ team

Josh Holdaway

unread,
May 18, 2023, 11:26:11 AM5/18/23
to rabbitmq-users
That's good news its working for you... However, it still is not working for me.  :-(
I updated to 3.11.16 to make sure I'm on the latest.
rabbitmqdetails.png
Does this all look good? 
Is there anything else I can check ?


Josh Holdaway

unread,
May 18, 2023, 11:48:41 AM5/18/23
to rabbitmq-users
Also as a FYI, If use this environment variable in my docker compose and remove the per queue timeout, it works:
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbit consumer_timeout  300000

However, I would like to use the per queue timeout.

Michal Kuratczyk

unread,
May 18, 2023, 6:50:30 PM5/18/23
to rabbitm...@googlegroups.com
Looking at the code, I don't really see how that may just not work at all unless you have consumer_tick_interval set to some non-standard value.
The default is 60s, which is why there's this one extra minute - it's only evaluated once a minute.



RabbitMQ team

Josh Holdaway

unread,
May 19, 2023, 12:13:14 PM5/19/23
to rabbitmq-users
Yeah its strange.  I haven't changed anything else :-(
Reply all
Reply to author
Forward
0 new messages