June 2018
Intermediate to advanced
596 pages
12h 39m
English
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(); ...Read now
Unlock full access