Created
October 4, 2010 19:58
-
-
Save kitplummer/610315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.dozersoftware.snap.pidgeon; | |
| import java.io.IOException; | |
| import java.net.DatagramPacket; | |
| import java.net.InetAddress; | |
| import java.net.MulticastSocket; | |
| import java.util.logging.Logger; | |
| import javax.jms.Connection; | |
| import javax.jms.JMSException; | |
| import javax.jms.Message; | |
| import javax.jms.MessageConsumer; | |
| import javax.jms.MessageListener; | |
| import javax.jms.TextMessage; | |
| import javax.jms.Session; | |
| import javax.jms.Topic; | |
| import org.apache.activemq.ActiveMQConnectionFactory; | |
| public class PidgeonOut implements MessageListener { | |
| private static final Logger log = | |
| Logger.getLogger(PidgeonOut.class.getName()); | |
| private String m_ip; | |
| private String m_port; | |
| //private boolean m_end; | |
| private String m_url = "tcp://localhost:61616"; | |
| private String m_out_topic; | |
| private Connection connection; | |
| private Session session; | |
| private Topic topic; | |
| public void run(){ | |
| try { | |
| ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(m_url); | |
| connection = factory.createConnection(); | |
| session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); | |
| log.info("Setting Pidgeon to listen on topic: " + m_out_topic); | |
| topic = session.createTopic(m_out_topic); | |
| MessageConsumer consumer = session.createConsumer(topic); | |
| consumer.setMessageListener(this); | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment