Commit f2b9d650 authored by Andre Freyssinet's avatar Andre Freyssinet

Minor changes.

parent 84648206
...@@ -40,14 +40,15 @@ public class MsgListener implements MessageListener { ...@@ -40,14 +40,15 @@ public class MsgListener implements MessageListener {
public void onMessage(Message msg) { public void onMessage(Message msg) {
try { try {
String topic = msg.getStringProperty("mqtt_topic");
if (msg instanceof TextMessage) if (msg instanceof TextMessage)
System.out.println(who + " receive on mqs queue: " + ((TextMessage) msg).getText()); System.out.println(who + " receive on mqs queue: " + ((TextMessage) msg).getText() + "\nfrom: " + topic);
else if (msg instanceof BytesMessage) { else if (msg instanceof BytesMessage) {
BytesMessage m = (BytesMessage) msg; BytesMessage m = (BytesMessage) msg;
int len = (int) m.getBodyLength(); int len = (int) m.getBodyLength();
byte[] payload = new byte[len]; byte[] payload = new byte[len];
len = m.readBytes(payload); len = m.readBytes(payload);
System.out.println(who + " receive on mqs queue [" + len + ", " + payload.length + "]: " + new String(payload)); System.out.println(who + " receive on mqs queue [" + len + ", " + payload.length + "]: " + new String(payload) + "\nfrom: " + topic);
} }
} }
catch (JMSException exc) { catch (JMSException exc) {
......
...@@ -56,6 +56,7 @@ public class Producer { ...@@ -56,6 +56,7 @@ public class Producer {
for (int i = 1; i < 11; i++) { for (int i = 1; i < 11; i++) {
String str = "Joram message number " + i + " sent through distribution bridge queue."; String str = "Joram message number " + i + " sent through distribution bridge queue.";
msg.writeBytes(str.getBytes()); msg.writeBytes(str.getBytes());
msg.setStringProperty("mqtt_topic", "/topic/toto");
System.out.println("send msg = " + str); System.out.println("send msg = " + str);
bridgeProducer.send(msg); bridgeProducer.send(msg);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment