I am using a message broker called Solace (similar to Tibco in term of its APIs), but this question applies to message brokers in general as well.
There is a callback method XMLMessageListener#onReceive(), which dumps the requests from clients. The question is, when multiple requests rush in simultaneously, will they queue up to be processed? For instance, request #2 won't enter the method onReceive until request #1 is processed or offloaded by a subtask?
It's the only way I can image how a message broker ensure the thread safety in this scenario. Can anyone correct me if I am wrong?
well, i don't know about XMLMessageListener#onReceive(), but the jms MessageListener http://docs.oracle.com/javaee/5/api/javax/jms/MessageListener.html states the threading contract specifically in the javadoc:
"Each session must insure that it passes messages serially to the listener. "
If you are using broker specific API's, though, then the behavior is whatever that broker implementation specifies.