Implementing JMS topic subscriber

We will now implement a topic subscriber class to receive messages published to the topic we created earlier. Create a CourseTopicSubscriber class in the packt.jee.eclipse.jms package with the following content:

package packt.jee.eclipse.jms; 
//skipping imports 
public class CourseTopicSubscriber { 
 
  private TopicConnection connection; 
  private TopicSession session; 
  private Topic topic; 
 
  private String subscriberName; 
 
  public CourseTopicSubscriber(String name) throws Exception{ 
 
    this.subscriberName = name; 
 
    InitialContext initCtx = new InitialContext(); 
    TopicConnectionFactory connectionFactory =  (TopicConnectionFactory)initCtx.lookup("jms/CourseManagemenCF"); connection = connectionFactory.createTopicConnection(); ...

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.