Search code examples
rabbitmqspring-rabbit

Pushing messages to new subscribers


I am creating a bulk video processing system using spring-boot. Here the user will provide all the video related information through an xlsx sheet and we will process the videos in the backend. I am using the Rabbitmq for queuing up the request. Let say a user has uploaded a sheet with 100 rows,then there will be 100 messages in the Rabbitmq queue. In the back-end, we are auto-scaling the subscribers (servers). So we will start with one subscriber-only and based on the load (number of messages in the queue) we will scale up to 15 subscribers. But our producer is very fast and it allocating all the messages to our first subscriber (before other subscribers are coming up) and all our new subscriber are not getting any messages from the queue. If all the subscribers are available before producer started pushing the messages then it is allocating the messages to all servers.

Please provide me a solution of how can our new subscribers pull the messages from the queue that were produced earlier.


Solution

  • You are probably being affected by the listener container prefetchCount property - it defaults to 250 with recent versions (since 2.0).

    So the first consumer will get up to 250 messages when it starts.

    It sounds like you should reduce it to a small number, even all the way down to 1 so only one message is outstanding at each consumer.