none
Connection issue from AMQP client

    Question

  • Hi,

    I am not able to connect to Service Bus from AMQP client. Using latest Apache QPID JMS 0.20.0 library for writing a simple client for Service Bus. 

    The code is below.

    My servicebus.properties contains 

    connectionfactory.SBCF = amqps://tumatest.servicebus.windows.net?jms.username=RootManageSharedAccessKey&jms.password=[key]&amqp.idleTimeout=220000&jms.receiveLocalOnly=true

    queue.QUEUE = tumaqueue

    Java code:

            // Configure JNDI environment
            Hashtable<String, String> env = new Hashtable<String, String>();
            //env.put(Context.INITIAL_CONTEXT_FACTORY,                    "org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory");
    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
            env.put(Context.PROVIDER_URL, "servicebus.properties");
            Context context = new InitialContext(env);

            // Look up ConnectionFactory and Queue
            ConnectionFactory cf = (ConnectionFactory) context.lookup("SBCF");
    Destination queue = (Destination) context.lookup("QUEUE");

            // Create Connection
            connection = cf.createConnection();

            // Create sender-side Session and MessageProducer
            sendSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            sender = sendSession.createProducer(queue);

    I get exception in below line while creating session.

    sendSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    javax.jms.JMSException: Cannot send to a non-connected transport.
            at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:86)
            at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:108)
            at org.apache.qpid.jms.JmsConnection.createResource(JmsConnection.java:608)
            at org.apache.qpid.jms.JmsConnection.createResource(JmsConnection.java:592)
            at org.apache.qpid.jms.JmsConnection.createJmsConnection(JmsConnection.java:507)
            at org.apache.qpid.jms.JmsConnection.createSession(JmsConnection.java:296)
            at SimpleSenderReceiver.<init>(SimpleSenderReceiver.java:39)
            at SimpleSenderReceiver.main(SimpleSenderReceiver.java:58)
    Caused by: java.io.IOException: Cannot send to a non-connected transport.
            at org.apache.qpid.jms.transports.netty.NettyTcpTransport.checkConnected(NettyTcpTransport.java:339)
            at org.apache.qpid.jms.transports.netty.NettyTcpTransport.allocateSendBuffer(NettyTcpTransport.java:228)
            at org.apache.qpid.jms.provider.amqp.AmqpProvider.pumpToProtonTransport(AmqpProvider.java:954)
            at org.apache.qpid.jms.provider.amqp.AmqpProvider$5.run(AmqpProvider.java:385)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)

    What is going wrong here? No error is thrown in line

            connection = cf.createConnection();

    Do I need to set transport.trustStoreLocation to trust store with Microsoft Azure certificates? If yes How I will download Azure certificate to my local store?

    Monday, March 06, 2017 11:23 AM

All replies

  • Are you following any documentation for those steps?

    And also, you can refer the SO link where the similar issue has been discussed.

    Tuesday, March 07, 2017 8:54 AM
    Moderator