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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.