Announcement Announcement Module
Collapse
No announcement yet.
Need to set concurrent-consumers to 0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to set concurrent-consumers to 0

    Hello,
    We externalized all our spring configuration parameters to be able to modify them easily in production environment.
    We a group of servers that run our application and we would like to have only some dedicated servers to listen to queues and process messages. The same code/application is deployed on all servers, but they have different configuration settings.

    In this particular case, we need to set the number of concurrent consumers to 0 for those which are not supposed to listen/consume messages. The current implementation (1.1.2 and 1.1.3) throws an exception on 0.

    <rabbit:listener-container connection-factory="myConnectionFactory" concurrency="${noOfConsumers}" >
    <rabbit:listener ref="..." queues="..." />
    </rabbit:listener-container>

    We appreciate if it can be fixed in the next release, or if there is any other workaround to disable queue consumers on a server.


    Thanks,

  • #2
    A listener-container is a Lifecycle component, so the proper way to control whether it's active or not is to call start() and stop() on that instance. By default the 'autoStartup' property is TRUE, so if you want the listener-container to be disabled until explicitly started, you would need to set that to FALSE.

    The "concurrent-consumers" itself must require a positive value; it's more like a thread pool where having 0 is an invalid state.

    Hope that helps.
    -Mark

    Comment


    • #3
      Thanks Mark,

      Managed to set the auto-startup attribute based on the value of an external property. I post my solution here that might be useful for someone else too.
      Code:
      	<rabbit:listener-container 
      		connection-factory="connectionFactory" 
      		auto-startup="#{ ${noOfConsumers} > 0}"
      		concurrency="#{ ${noOfConsumers} > 0 ? ${noOfConsumers} : 1}" >  
              ...
      When ${noOfConsumers} is 0 the auto-startup would be false but we still need to pass a non-zero value to "concurrency" just to avoid exception.

      Thanks,
      Last edited by rasadoll; Nov 22nd, 2012, 09:47 PM.

      Comment

      Working...
      X