Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.profiler.consumer;
- import javax.jms.*;
- import org.apache.activemq.ActiveMQConnection;
- import org.apache.activemq.ActiveMQConnectionFactory;
- public class Consumer {
- public static TextListener listener;
- // = localhost
- private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;
- // Name of the queue
- private static String subject = "Profiler";
- public static void main(String[] args) throws JMSException {
- // Getting JMS connection from the server
- ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
- Connection connection = connectionFactory.createConnection();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Destination destination = session.createQueue(subject);
- MessageConsumer consumer = session.createConsumer(destination);
- connection.start();
- listener = new TextListener();
- consumer.setMessageListener(listener);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement