Adding multiple queue listeners

Queues are meant for point-to-point communication, but this does not mean that there can't be more than one listener for a queue. However, only one listener gets the message. Furthermore, it is not guaranteed that the same listener will get the message every time. If you want to test this, add one more instance of CourseQueueReceiver in JMSReceiverInitServlet. Let's add the second instance with a different name, say Receiver2:

@WebServlet(urlPatterns="/JMSReceiverInitServlet", loadOnStartup=1) public class JMSReceiverInitServlet extends HttpServlet { private CourseQueueReceiver courseQueueReceiver = null; private CourseQueueReceiver courseQueueReceiver1 = null; @Override public void init(ServletConfig config) ...

Get Java EE 8 Development with Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.