Specify consumer_tag when using channel.consume()

39 views
Skip to first unread message

juanschwartz

unread,
Feb 5, 2024, 11:41:33 AMFeb 5
to Pika
I am having trouble setting a custom consumer_tag(the name of a kubernetes POD) using channel.consumer(). I see it is a parameter for basic_consume(), but my use case requires the inactivity_timeout option in the consume() method.

The reason I want to do this is so that I can do custom scaling depending upon the RabbitMQ queue size and the status of the consumer channel. If the queue size is backing off and the consumer channel is idle, I want to be able to terminate those pods that were scaled up to handle the influx of messages.

Regards,

Juan

Luke Bakken

unread,
Feb 5, 2024, 7:29:04 PMFeb 5
to Pika
Hi Juan,

Please provide a git repository with a runnable code example showing what you have tried.

Thank you,
Luke

juanschwartz

unread,
Feb 5, 2024, 10:06:13 PMFeb 5
to Pika
Hello,

I couldn't find an avenue to really pursue it after following the docs.

basic_consume accepts a parameter called consumer_tag which allows you to specify a custom tag. The normal consume method lacks this parameter and when I searched the entire documentation for consumer_tag, the only thing that comes up is the basic_consume method.

I scoured the documentation and don't see a way to specify a tag in the consume() method the way you can do it in basic_consume()

I do see a way to get a dynamically generated consumer tag after the channel is established, but I was hoping to feed an env variable from a container to the consumer tag so that I can correlate the pod to the consumer.

Regards,

Jimmy

Luke Bakken

unread,
Jun 11, 2024, 9:07:29 AMJun 11
to Pika
Hi Jimmy,

Apologies that it has taken so long to return to this. I have been busy working on the next major release of the .NET client.

Indeed, there is no way for an end-user to provide a consumer tag when using consume. A PR to implement it would be welcome.

Thanks,
Luke

Reply all
Reply to author
Forward
0 new messages