Search code examples
rabbitmqspring-cloudspring-cloud-streamspring-rabbit

How to set spring.cloud.stream.instanceCount with RabbitMQ consumers on autoscale environment?


I'm running RabbitMq consumers using the spring cloud infrastructure. The documentation state the following:

spring.cloud.stream.instanceCount
The number of deployed instances of an application. Must be set for partitioning on the producer side. Must be set on the consumer side when using RabbitMQ and with Kafka if autoRebalanceEnabled=false.
Default: 1.
spring.cloud.stream.instanceIndex
The instance index of the application: A number from 0 to instanceCount - 1. Used for partitioning with RabbitMQ and with Kafka if autoRebalanceEnabled=false. Automatically set in Cloud Foundry to match the application’s instance index.

My consumers are running on an auto-scaling environment - when the queue is getting above a threshold, more consumer instances are raised, and when it gets down again some consumers are shutdown.

So how should I define those parameters?
Are they really mandatory?


Solution

  • These properties are only applicable when using partitioned queues.

    The rabbitmq binder does not support auto-scaling when using partitioning.

    As long as you are not using partitioning, you can ignore them.