How does a client accommodate asynchronous message notifications from the JMS server?
Location: http://www.jguru.com/faq/view.jsp?EID=1214 Created: Nov 22, 1999 Modified: 1999-11-29 12:43:59.136 Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9) To receive messages asynchronously, a client must: • Implement javax.jms.MessageListener: public interface MessageListener { void onMessage(Message message); } • Register the message handler using setMessageListener(): … subscriber = session.createSubscriber(topic); SubscriberMessageThread smt = new SubscriberMessageThread(this); subscriber.setMessageListener(smt); con.start(); // start connection smt.start(); … The use of a listener for method notifications is similar to using listeners for event notification with graphical AWT clients. Note, however, that every AWT application has a screen-updater thread running in the background that keeps the application alive when main() completes its thread of execution. Certainly, JMS clients vary enormously in function but, in general, some thread of execution must be