Implementing JMS queue sender class

Let's create the CourseQueueSender class in the packt.jee.eclipse.jms package with the following content:

package packt.jee.eclipse.jms; 
 
//skipped imports 
 
public class CourseQueueSender { 
  private QueueConnection connection; 
  private QueueSession session; 
  private Queue queue; 
 
 
  public CourseQueueSender() throws Exception { 
    //Create JMS Connection, session, and queue objects 
    InitialContext initCtx = new InitialContext(); 
    QueueConnectionFactory connectionFactory =      (QueueConnectionFactory)initCtx. 
          lookup("jms/CourseManagemenCF"); 
    connection = connectionFactory.createQueueConnection(); 
    connection.start(); 
    session = connection.createQueueSession(false,  Session.AUTO_ACKNOWLEDGE); queue = (Queue)initCtx.lookup("jms/courseManagementQueue"); ...

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.