简体   繁体   中英

rabbit:listener-container attributes shared or not?

<rabbit:listener-container connection-factory="connectionFactory" concurrency="5" error-handler="genericErrorHandler" prefetch="10">
    <rabbit:listener ref="SmsListener" method="listen" queue-names="smsQueue" />
    <rabbit:listener ref="TestListener" method="listen" queue-names="testQueue" />
    <rabbit:listener ref="VaultListener" method="listen" queue-names="vaultQueue" />
    <rabbit:listener ref="AggregatedDataListener" method="listen" queue-names="AggregatedHourlyQueue" />
</rabbit:listener-container>

With this configuration above I would like to know whether the attributes(eg concurrency) of the container are shared among all the listeners or do every listener have a container of their own and the <rabbit:listener-container /> is just a namespace (as pointed out in this answer )?

In addition since there is one channel per thread, does this imply that when the channels are busy consuming messages from one queue, meanwhile the other queue sharing the container piles up the messages and waits on the channel ?

Also I would like to know the better approach of defining listener:

  1. Every listener should be enclosed in their own container.

    or

  2. Listeners can be enclosed in the same container as shown in the above code snippet.

As the question you cited explains, each <listener/> element gets its own container, the <listener-container/> outer element is simply a convenience to save having to specify its attributes on each listener. They are not "shared" in the sense that the threads are shared across the containers.

In this case, each container gets 5 threads; there is no relationship between the individual containers at runtime.

  1. Putting each listener in a separate container element has no difference at runtime to what you have now.
  2. There is no way to have multiple "listeners" in on container, although you can specify multiple queues for each listener, in which case the threads are indeed shared across those queues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM