Reputation: 25
I have configured jms queue where multiple listeners are listening to same queue and if i push multiple objects into my queue which listener going to get the messages? is there any guarantee that to know which listener listen my message?
Upvotes: 0
Views: 2370
Reputation: 32066
Did you custom code the listeners? If so, just add some code to generate a unique id for each listener, save the id in an instance variable. When the listener gets a message, output the event with the id to standard log file.
public class MyListener extends MessageListener {
private static int listeners;
private int id;
public MyListener(){
this.id = generateUniqueId();
}
public void onMessage(Message m){
System.out.println("Listener " + id + " got message!");
//do stuff here
}
private synchronized static int generateUniqueId(){
return listeners += 1;
}
}
Upvotes: 2
Reputation: 5005
Hi user2336442 (nice name by the way...), if two receivers listen on the same queue there's no guarantee about which one of them will receive the message first, since they follow the principle first-come first-served. If the two listeners are on the same machine (same ip addresses) there's no way to understand which one received the message, otherwise you can use the console to roughly see where the messages have been sent...
Upvotes: 0