OK, now for a my noobie question...
I am using a Java server to publish message to a Rabbit queue like so:
-----------------------------------------------------------------------------------------
public static void SendMessage(String queue, String message){
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
log.debug("factory created");
try (Connection connection = factory.newConnection();
Channel channel = connection.createChannel()) {
channel.queueDeclare(queue, false, false, false, null);
channel.basicPublish("", queue, null, message.getBytes());
} catch (IOException ex ){
log.error("MessageManager.SendMessage error sending message " + ex);
} catch (TimeoutException ex){
log.error("MessageManager.SendMessage timeout sending message " + ex);
}
}
--------------------------------------
Fine, I can see message on the Rabbit admin.
I use Paho eclipse on the Javascript client side to consume from the queue
----------------------------------------
function onloadFunction(){
// Create a client instance
client = new Paho.MQTT.Client("localhost", 15675, "/ws", "/:mqtt-user");
// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
// connect the client
client.connect({onSuccess:onConnect});
}
function onConnect() {
console.log("onConnect");
client.subscribe("vom", {qos: 1});
}
// called when the client loses its connection
function onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost:"+responseObject.errorMessage);
}
}
// called when a message arrives
function onMessageArrived(message) {
console.log("onMessageArrived:"+message.payloadString);
}
------------------------------------------------------------------------
The write to the "vom" queue on the server.
I have tried variations per what I understand is the difference between Rabbit queues and MQTT topics (amq/topic/vom, /topic/vom, /vom, etc, etc, etc)
Nothing seems to work. It sits for a while and then eventually disconnects.
--------------------------
onConnect
onConnectionLost:AMQJS0008I Socket closed.
-------------------------
I am sure I am doing something very simple wrong, What am I missing?
Thanks,
Bryan