Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. package foo.barr.ui.struts;
  2.  
  3. import org.apache.log4j.Logger;
  4.  
  5. import javax.jms.Connection;
  6. import javax.jms.ConnectionFactory;
  7. import javax.jms.Destination;
  8. import javax.jms.JMSException;
  9. import javax.jms.Message;
  10. import javax.jms.MessageConsumer;
  11. import javax.jms.MessageListener;
  12. import javax.jms.Session;
  13. import javax.jms.TextMessage;
  14. import org.apache.activemq.ActiveMQConnection;
  15. import org.apache.activemq.ActiveMQConnectionFactory;
  16.  
  17. /**
  18. * Created on: 13:50
  19. *
  20. * @author <a href="mailto:jason.hunsinger@evisions.com">Jason Hunsinger</a>
  21. */
  22. public class OpportunityListSubscriber implements MessageListener
  23. {
  24.  
  25. private static final Logger log = Logger.getLogger(OpportunityListSubscriber.class);
  26.  
  27. private static ConnectionFactory factory = null;
  28. private static Connection connection = null;
  29. private static Session session = null;
  30. private static Destination destination = null;
  31. private static MessageConsumer consumer = null;
  32.  
  33. public void startup()
  34. {
  35. log.info("starting up");
  36.  
  37. try
  38. {
  39. factory = new ActiveMQConnectionFactory(
  40. ActiveMQConnection.DEFAULT_BROKER_URL);
  41. connection = factory.createConnection();
  42. connection = factory.createConnection();
  43. connection.start();
  44. session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  45. destination = session.createQueue("TEST.FOO");
  46. consumer = session.createConsumer(destination);
  47. consumer.setMessageListener(this);
  48. }
  49.  
  50. catch (JMSException e)
  51. {
  52. e.printStackTrace();
  53. }
  54. }
  55.  
  56.  
  57. @Override
  58. public void onMessage(final Message message)
  59. {
  60. TextMessage textMessage = (TextMessage) message;
  61. log.debug("the message " + textMessage);
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement