public JMSSink(String tcfBindingName,
String topicBindingName,
String username,
String password) {
try {
Context ctx = new InitialContext();
TopicConnectionFactory topicConnectionFactory;
topicConnectionFactory = (TopicConnectionFactory) lookup(ctx,
tcfBindingName);
TopicConnection topicConnection =
topicConnectionFactory.createTopicConnection(username,
password);
topicConnection.start();
TopicSession topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic)ctx.lookup(topicBindingName);
TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic);
topicSubscriber.setMessageListener(this);
} catch(Exception e) {
logger.error("Could not read JMS message.", e);
}
}
|