What is better design
Is it better to have one listener and separate processing in this listener for two types of emssages.
Or to have two listeners for processing and separate it by header’s?
e.g. for different type of class. or interfaces.
—–edit
Instead of using selectors. I can have let’s say list of Handlers(interface) and just iterate through registered(via IOC) handlers and select the one which can handle message. It’s separated as well but differently,what do you think is better?
Use multiple listeners.
Why would you want to write code that duplicates the existing capabilities of the technology you are already using. I use the word duplication here in only its simplest sense since JMS can support fairly complex decision making process in routing of your messages.
Other considerations are the ability to distribute the workload based on the selectors for each listeners. With multiple listeners you can configure the number of threads by message type and easily change that value as necessary. Of course you could do this yourself as well, but why would you?