From 5c762750101f12abd51621355a871e42fd9c7a33 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 4 May 2014 23:34:16 +0200 Subject: o Getting the web configuration to work. --- .../plugins/activemq/MessageListenerMain.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/test/java/org/jenkinsci/plugins/activemq/MessageListenerMain.java (limited to 'src/test/java') diff --git a/src/test/java/org/jenkinsci/plugins/activemq/MessageListenerMain.java b/src/test/java/org/jenkinsci/plugins/activemq/MessageListenerMain.java new file mode 100644 index 0000000..ed7def3 --- /dev/null +++ b/src/test/java/org/jenkinsci/plugins/activemq/MessageListenerMain.java @@ -0,0 +1,42 @@ +package org.jenkinsci.plugins.activemq; + +import org.apache.activemq.ActiveMQConnectionFactory; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; +import java.io.IOException; + +public class MessageListenerMain { + public static void main(String[] args) throws JMSException, IOException { + ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616"); + + Connection connection = connectionFactory.createConnection(); + connection.start(); + System.out.println("Connected"); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Topic topic = session.createTopic(ActiveMqClient.TOPIC_NAME); + MessageConsumer consumer = session.createConsumer(topic); + + while (true) { + System.out.println("Waiting for messages"); + Message m = consumer.receive(); + + if (m instanceof TextMessage) { + TextMessage message = (TextMessage) m; + + System.out.println("--------------------------------"); + System.out.println(message.getText().trim()); + System.out.println("--------------------------------"); + } else { + System.out.println("Unknown message: " + m); + } + } + } +} -- cgit v1.2.3