Pedro Marques created AMQ-4576:
----------------------------------

             Summary: MQTT BlockingConnection.receive fails when subscribing 
multiple topics
                 Key: AMQ-4576
                 URL: https://issues.apache.org/jira/browse/AMQ-4576
             Project: ActiveMQ
          Issue Type: Bug
    Affects Versions: 5.9.0
            Reporter: Pedro Marques


When more than one topic is supplied to BlockingConnection.subscribe the 
BlockingConnection.receive fails and the following exception is thrown:
{code}
java.io.IOException: Could not connect: CONNECTION_REFUSED_SERVER_UNAVAILABLE
        at 
org.fusesource.mqtt.client.CallbackConnection$LoginHandler$1.onTransportCommand(CallbackConnection.java:331)
        at 
org.fusesource.hawtdispatch.transport.TcpTransport.drainInbound(TcpTransport.java:659)
        at 
org.fusesource.hawtdispatch.transport.SslTransport.drainInbound(SslTransport.java:264)
        at 
org.fusesource.hawtdispatch.transport.TcpTransport$6.run(TcpTransport.java:538)
        at 
org.fusesource.hawtdispatch.internal.NioDispatchSource$3.run(NioDispatchSource.java:209)
        at 
org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100)
        at 
org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77)
{code}
Code example:
{code}
MQTT = new MQTT();
mqtt.setHost(url);
mqtt.setClientId(clientId);
mqtt.setUserName(user);
mqtt.setPassword(password);
mqtt.setCleanSession(false);

BlockingConnection connection = mqtt.blockingConnection();
connection.connect();
Topic[] topics = {new Topic("TopicA", QoS.EXACTLY_ONCE), new Topic("TopicB", 
QoS.EXACTLY_ONCE)};
byte[] qoses = connection.subscribe(topics);
while (true) {
    Message message = connection.receive();
    byte[] payload = message.getPayload();
    String messageContent = new String(payload);
    System.out.println("Received message from topic: " + message.getTopic() + " 
Message content: " + messageContent);
    message.ack();
}
{code}
The test failed when using the current fusesource client (1.5) on ActiveMQ 5.9, 
on Mosquitto mqtt the code works correctly.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to