darkstar
darkstar

Reputation: 157

Auto spawn rabbit mq listener

I'm working on an application where-in I have a listener on a rabbit mq queue. Depending on the kind of message, the listener goes ahead and performs a task. My problem is I need a way to spawn a new listener if a single listener isn't able to cope up with the queue. As far as I can tell, I can use the rabbitmq json api to find the len of the queue and take actions based on that. So, I write a script that checks using curl the queue length and spawns a new listener process. Am I on the right path here? Is there a better way to achieve this? I'm looking for a solution that kinda scales with load to a certain limit atleast.

Upvotes: 2

Views: 692

Answers (1)

eandersson
eandersson

Reputation: 26362

Checking the RabbitMQ API to see the length of the queue is one way, and it would definitely work.

You should try to predict when the load is spiking so that you slowly can increase the number of consumers if needed, so that you don't see a sudden spike of instances spawning. Having many instances spawning simultaneously could cause unnecessary load on your system.

Upvotes: 1

Related Questions