Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package foo.barr.ui.struts;
- import org.apache.log4j.Logger;
- import javax.jms.Connection;
- import javax.jms.ConnectionFactory;
- import javax.jms.Destination;
- import javax.jms.JMSException;
- import javax.jms.Message;
- import javax.jms.MessageConsumer;
- import javax.jms.MessageListener;
- import javax.jms.Session;
- import javax.jms.TextMessage;
- import org.apache.activemq.ActiveMQConnection;
- import org.apache.activemq.ActiveMQConnectionFactory;
- /**
- * Created on: 13:50
- *
- * @author <a href="mailto:jason.hunsinger@evisions.com">Jason Hunsinger</a>
- */
- public class OpportunityListSubscriber implements MessageListener
- {
- private static final Logger log = Logger.getLogger(OpportunityListSubscriber.class);
- private static ConnectionFactory factory = null;
- private static Connection connection = null;
- private static Session session = null;
- private static Destination destination = null;
- private static MessageConsumer consumer = null;
- public void startup()
- {
- log.info("starting up");
- try
- {
- factory = new ActiveMQConnectionFactory(
- ActiveMQConnection.DEFAULT_BROKER_URL);
- connection = factory.createConnection();
- connection = factory.createConnection();
- connection.start();
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- destination = session.createQueue("TEST.FOO");
- consumer = session.createConsumer(destination);
- consumer.setMessageListener(this);
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
- }
- @Override
- public void onMessage(final Message message)
- {
- TextMessage textMessage = (TextMessage) message;
- log.debug("the message " + textMessage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement