Reputation: 3913
I have a question about DefaultMessageListenerContainer with multiple concurrentConsumers, the container creates differents sessions for each consumer but the problem for me is that the container allow only one message listner instance shared between all consumers, like this i cannot receive many messages and treat them in parallel because each thread will wait for the listener to be available, it is not better to allow each concurrent Consumer to have an exclusive instance of message listener to treat message ?
Upvotes: 0
Views: 2296
Reputation: 174494
The container is designed for use with thread-safe (stateless) listeners - i.e. no unprotected global state.
It sounds like you use synchronized
to protect the state, which allows only one listener thread at a time.
If you can't make your listener bean thread-safe, you need to use multiple containers, each with a different listener bean (you can use prototype scope so each container gets its own bean) with concurrency=1.
Upvotes: 1