Hi QPID,

seemed to me, it is a bug for amqp-1-0 java client version 0.24.

I expect when amqp-1-0 client connects to amqp-0-9-1-enable broker, client
should be able to close connection because it supports amqp-1-0 only.

Actually, client could not close connection and run into deadlock because
when it sends frames for protocol handshake, on broker side broker does not
support amqp-1-0, sends back its supported version and closes TCP
connection. An unhandled exception occurs at client that causes client wait
forever.

tracelog:
SEND[localhost/127.0.0.1:5672] : AMQP\x03\x01\x00\x00
RECV [localhost/127.0.0.1:5672] : AMQP\x00\x00\x09\x01
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at 
org.apache.qpid.amqp_1_0.client.Connection.doRead(Connection.java:388)
        at 
org.apache.qpid.amqp_1_0.client.Connection.access$1(Connection.java:379)
        at org.apache.qpid.amqp_1_0.client.Connection$2.run(Connection.java:259)
        at java.lang.Thread.run(Unknown Source)

Program to test as below

import org.apache.qpid.amqp_1_0.transport.Container;
import org.apache.qpid.amqp_1_0.type.UnsignedInteger;

public class Consumer {

        private static Container container = new Container();
        private static String host = "localhost";
        private static String remotehost = "localhost";
        private static int port = 5672;
        private static String username = "guest";
        private static String password = "guest";
        private static boolean ssl = false;
        
        private static String queueName = "queue";

        public static void main(String[] args) {
                Consumer consumer = new Consumer();
                consumer.receive();
        }

        public void receive() {
                try {
                        Connection conn = new Connection(host, port, username, 
password, 65536,
container, remotehost, ssl, -1);
                        Session session = conn.createSession();
                        Receiver r = session.createReceiver(queueName, 
AcknowledgeMode.ALO, null,
true, null, null);
                        r.setCredit(UnsignedInteger.valueOf(100), false);

                        for (;;) {
                                Message m = r.receive(10000L);
                                if (m == null) {
                                        break;
                                }
                                r.acknowledgeAll(m);
                                System.out.println("Received Message : " + 
m.getPayload());
                        }
                        r.close();
                        r.getSession().close();
                        r.getSession().getConnection().close();
                } catch (ConnectionException e) {
                        e.printStackTrace();
                }
        }
}



--
View this message in context: 
http://qpid.2158936.n2.nabble.com/Deadlock-when-using-amqp-1-0-client-to-connect-to-amqp-0-9-1-broker-tp7601480.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org
For additional commands, e-mail: users-h...@qpid.apache.org

Reply via email to