summaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/jenkinsci/plugins/activemq/MessageListenerMain.java42
1 files changed, 42 insertions, 0 deletions
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);
+ }
+ }
+ }
+}