You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Wayna Runa <wa...@gmail.com> on 2014/12/16 17:59:29 UTC

Cannot connect to RabbitMQ 3.3.5 using qpid-client-0.30

Hi there,

I have modified the "Hello.java" sample of qpid-client-0.30 JMS client to
connect to RabbitMQ v3.3.5, but this does not work.

My JNDI config (hello.properties) is:

-----------------------.-----------------------
java.naming.factory.initial =
org.apache.qpid.jndi.PropertiesFileInitialContextFactory
#### RabbitMQ v3.3.5
connectionfactory.myRabbitMQConnectionFactory1 = amqp://admin:xxx@clientid
/DES_DEV?brokerlist='tcp://10.105.135.53:5672'
connectionfactory.myRabbitMQConnectionFactory2 = amqp://admin:xxx@clientid
/?brokerlist='tcp://10.105.135.53:5672'
queue.myJNDIRabbitMQQueue1 = q.test1
queue.myJNDIRabbitMQQueue2 = q.test2
-----------------------.-----------------------

And my updated Hello.java is:

-----------------------.-----------------------
import java.io.InputStream;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Hello {

    public Hello() {
    }

    public static void main(String[] args) {
        Hello hello = new Hello();
        hello.runTest();
    }

    private void runTest()  {
        try (InputStream resourceAsStream =
this.getClass().getResourceAsStream("hello.properties")) {
            System.setProperty("qpid.amqp.version", "0-91");
            Properties properties = new Properties();
            properties.load(resourceAsStream);
            Context context = new InitialContext(properties);

            ConnectionFactory connectionFactory = (ConnectionFactory)
context.lookup("myRabbitMQConnectionFactory1");
            //ConnectionFactory connectionFactory = (ConnectionFactory)
context.lookup("myRabbitMQConnectionFactory2");
            Connection connection = connectionFactory.createConnection();
            connection.start();
            Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

            Queue queue = (Queue) context.lookup("myJNDIRabbitMQQueue1");
            //Queue queue = (Queue) context.lookup("myJNDIRabbitMQQueue2");
            MessageProducer messageProducer = session.createProducer(queue);
            TextMessage message = session.createTextMessage("Hello world
!!");
            messageProducer.send(message);

            System.out.println(message.getText());
            connection.close();
            context.close();
        } catch (Exception exp) {
            exp.printStackTrace();
        }
    }
}
-----------------------.-----------------------


If I use (with VIRTUAL HOST):

connectionfactory.myRabbitMQConnectionFactory1 = amqp://admin:xxx@
*clientid/DES_DEV*?brokerlist='tcp://10.105.135.53:5672'

I have this error:

-----------------------.-----------------------
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
javax.jms.JMSException: Error creating connection: Exception thrown against
AMQConnection:
Host: 10.105.135.53
Port: 5672
Virtual Host: DES_DEV
Client ID: clientid
Active session count: 0: org.apache.qpid.AMQDisconnectedException:
Connection could not be established: Connection reset
    at
org.apache.qpid.client.AMQConnectionFactory.createConnection(AMQConnectionFactory.java:128)
    at info.intix.rabbitmq.samples.Hello.runTest(Hello.java:39)
    at info.intix.rabbitmq.samples.Hello.main(Hello.java:21)
Caused by: org.apache.qpid.AMQConnectionFailureException: Exception thrown
against AMQConnection:
Host: 10.105.135.53
Port: 5672
Virtual Host: DES_DEV
Client ID: clientid
Active session count: 0: org.apache.qpid.AMQDisconnectedException:
Connection could not be established: Connection reset
    at org.apache.qpid.client.AMQConnection.<init>(AMQConnection.java:503)
    at
org.apache.qpid.client.AMQConnectionFactory.createConnection(AMQConnectionFactory.java:124)
    ... 2 more
Caused by: org.apache.qpid.AMQException: Woken up due to class
javax.jms.JMSException
    at
org.apache.qpid.client.util.BlockingWaiter.block(BlockingWaiter.java:195)
    at org.apache.qpid.client.state.StateWaiter.await(StateWaiter.java:114)
    at org.apache.qpid.client.state.StateWaiter.await(StateWaiter.java:91)
    at org.apache.qpid.client.*AMQConnectionDelegate_8_0*
.makeBrokerConnection(AMQConnectionDelegate_8_0.java:142)
    at
org.apache.qpid.client.AMQConnection.makeBrokerConnection(AMQConnection.java:647)
    at org.apache.qpid.client.AMQConnection.<init>(AMQConnection.java:429)
    ... 3 more
Caused by: javax.jms.JMSException: Exception thrown against AMQConnection:
Host: 10.105.135.53
Port: 5672
Virtual Host: DES_DEV
Client ID: clientid
Active session count: 0: org.apache.qpid.AMQDisconnectedException:
Connection could not be established: Connection reset
    at
org.apache.qpid.client.AMQConnection.exceptionReceived(AMQConnection.java:1313)
    at
org.apache.qpid.client.protocol.AMQProtocolHandler.closed(AMQProtocolHandler.java:285)
    at
org.apache.qpid.transport.network.io.IoReceiver.run(IoReceiver.java:222)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.qpid.AMQDisconnectedException: Connection could not
be established: Connection reset
    ... 3 more
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:196)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at
org.apache.qpid.transport.network.io.IoReceiver.run(IoReceiver.java:156)
-----------------------.-----------------------

In "Hello.java" i have defined the AMQP version to 0.91, but seems that is
not used. RabbitMQ v3.3.5 implements AMQP 0-9-1.

But, If I use (connectionfactory.myRabbitMQConnectionFactory2 =
amqp://admin:xxx@*clientid*/?brokerlist='tcp://10.105.135.53:5672'  -
without VIRTUAL HOST):

* There are not errors, seems the message was published... but there is not
messages in the queue.
* In the RabbitMQ web admin console I can see a new connection created.
This new connection has "Protocol = AMQP 0-9-1" and "Client = qpid 0.30 /
Java ...".
You can check it here:
https://www.dropbox.com/s/ek5r5qgvripewdz/rabbitmq-qpid-jms-conn-created.PNG?dl=0


Any help will be welcome.

Regards.

- WR

Re: Cannot connect to RabbitMQ 3.3.5 using qpid-client-0.30

Posted by Wayna Runa <wa...@gmail.com>.
Hi Nathan,

This works!

In RabbitMQ was necessary:

- to create virtual host with "/", for example: "/MY_VIRTUAL_HOST".
- to create a queue in above virtual host
- to  bind using a routing key with the same name of above queue

... and run Hello.java !

Regards.

- wr

Re: Cannot connect to RabbitMQ 3.3.5 using qpid-client-0.30

Posted by Nathan Kunkee <nk...@genome.wustl.edu>.
On 12/16/2014 10:59 AM, Wayna Runa wrote:
> Hi there,
>
> I have modified the "Hello.java" sample of qpid-client-0.30 JMS client to
> connect to RabbitMQ v3.3.5, but this does not work.
>
> My JNDI config (hello.properties) is:
>
> -----------------------.-----------------------
> java.naming.factory.initial =
> org.apache.qpid.jndi.PropertiesFileInitialContextFactory
> #### RabbitMQ v3.3.5
> connectionfactory.myRabbitMQConnectionFactory1 = amqp://admin:xxx@clientid
> /DES_DEV?brokerlist='tcp://10.105.135.53:5672'
> connectionfactory.myRabbitMQConnectionFactory2 = amqp://admin:xxx@clientid
> /?brokerlist='tcp://10.105.135.53:5672'
> queue.myJNDIRabbitMQQueue1 = q.test1
> queue.myJNDIRabbitMQQueue2 = q.test2
> -----------------------.-----------------------
>
> And my updated Hello.java is:
>
> -----------------------.-----------------------
> import java.io.InputStream;
> import java.util.Properties;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.naming.Context;
> import javax.naming.InitialContext;
>
> public class Hello {
>
>      public Hello() {
>      }
>
>      public static void main(String[] args) {
>          Hello hello = new Hello();
>          hello.runTest();
>      }
>
>      private void runTest()  {
>          try (InputStream resourceAsStream =
> this.getClass().getResourceAsStream("hello.properties")) {
>              System.setProperty("qpid.amqp.version", "0-91");
>              Properties properties = new Properties();
>              properties.load(resourceAsStream);
>              Context context = new InitialContext(properties);
>
>              ConnectionFactory connectionFactory = (ConnectionFactory)
> context.lookup("myRabbitMQConnectionFactory1");
>              //ConnectionFactory connectionFactory = (ConnectionFactory)
> context.lookup("myRabbitMQConnectionFactory2");
>              Connection connection = connectionFactory.createConnection();
>              connection.start();
>              Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
>              Queue queue = (Queue) context.lookup("myJNDIRabbitMQQueue1");
>              //Queue queue = (Queue) context.lookup("myJNDIRabbitMQQueue2");
>              MessageProducer messageProducer = session.createProducer(queue);
>              TextMessage message = session.createTextMessage("Hello world
> !!");
>              messageProducer.send(message);
>
>              System.out.println(message.getText());
>              connection.close();
>              context.close();
>          } catch (Exception exp) {
>              exp.printStackTrace();
>          }
>      }
> }
> -----------------------.-----------------------
>
>
> If I use (with VIRTUAL HOST):
>
> connectionfactory.myRabbitMQConnectionFactory1 = amqp://admin:xxx@
> *clientid/DES_DEV*?brokerlist='tcp://10.105.135.53:5672'
>
> I have this error:
>
> -----------------------.-----------------------
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
> details.
> javax.jms.JMSException: Error creating connection: Exception thrown against
> AMQConnection:
> Host: 10.105.135.53
> Port: 5672
> Virtual Host: DES_DEV
> Client ID: clientid
> Active session count: 0: org.apache.qpid.AMQDisconnectedException:
> Connection could not be established: Connection reset

Do the RabbitMQ logs say why the connection was dropped? While 
troubleshooting this, you'll probably want a window open to tail their 
logs. Qpid (implicitly) assumes that virtual hosts have a leading 
forward slash, while RabbitMQ does not. I had to specifically create my 
virtual hosts with a forward slash on RabbitMQ.

Hope that helps,
Nathan

>      at
> org.apache.qpid.client.AMQConnectionFactory.createConnection(AMQConnectionFactory.java:128)
>      at info.intix.rabbitmq.samples.Hello.runTest(Hello.java:39)
>      at info.intix.rabbitmq.samples.Hello.main(Hello.java:21)
> Caused by: org.apache.qpid.AMQConnectionFailureException: Exception thrown
> against AMQConnection:
> Host: 10.105.135.53
> Port: 5672
> Virtual Host: DES_DEV
> Client ID: clientid
> Active session count: 0: org.apache.qpid.AMQDisconnectedException:
> Connection could not be established: Connection reset
>      at org.apache.qpid.client.AMQConnection.<init>(AMQConnection.java:503)
>      at
> org.apache.qpid.client.AMQConnectionFactory.createConnection(AMQConnectionFactory.java:124)
>      ... 2 more
> Caused by: org.apache.qpid.AMQException: Woken up due to class
> javax.jms.JMSException
>      at
> org.apache.qpid.client.util.BlockingWaiter.block(BlockingWaiter.java:195)
>      at org.apache.qpid.client.state.StateWaiter.await(StateWaiter.java:114)
>      at org.apache.qpid.client.state.StateWaiter.await(StateWaiter.java:91)
>      at org.apache.qpid.client.*AMQConnectionDelegate_8_0*
> .makeBrokerConnection(AMQConnectionDelegate_8_0.java:142)
>      at
> org.apache.qpid.client.AMQConnection.makeBrokerConnection(AMQConnection.java:647)
>      at org.apache.qpid.client.AMQConnection.<init>(AMQConnection.java:429)
>      ... 3 more
> Caused by: javax.jms.JMSException: Exception thrown against AMQConnection:
> Host: 10.105.135.53
> Port: 5672
> Virtual Host: DES_DEV
> Client ID: clientid
> Active session count: 0: org.apache.qpid.AMQDisconnectedException:
> Connection could not be established: Connection reset
>      at
> org.apache.qpid.client.AMQConnection.exceptionReceived(AMQConnection.java:1313)
>      at
> org.apache.qpid.client.protocol.AMQProtocolHandler.closed(AMQProtocolHandler.java:285)
>      at
> org.apache.qpid.transport.network.io.IoReceiver.run(IoReceiver.java:222)
>      at java.lang.Thread.run(Thread.java:744)
> Caused by: org.apache.qpid.AMQDisconnectedException: Connection could not
> be established: Connection reset
>      ... 3 more
> Caused by: java.net.SocketException: Connection reset
>      at java.net.SocketInputStream.read(SocketInputStream.java:196)
>      at java.net.SocketInputStream.read(SocketInputStream.java:122)
>      at
> org.apache.qpid.transport.network.io.IoReceiver.run(IoReceiver.java:156)
> -----------------------.-----------------------
>
> In "Hello.java" i have defined the AMQP version to 0.91, but seems that is
> not used. RabbitMQ v3.3.5 implements AMQP 0-9-1.
>
> But, If I use (connectionfactory.myRabbitMQConnectionFactory2 =
> amqp://admin:xxx@*clientid*/?brokerlist='tcp://10.105.135.53:5672'  -
> without VIRTUAL HOST):
>
> * There are not errors, seems the message was published... but there is not
> messages in the queue.
> * In the RabbitMQ web admin console I can see a new connection created.
> This new connection has "Protocol = AMQP 0-9-1" and "Client = qpid 0.30 /
> Java ...".
> You can check it here:
> https://www.dropbox.com/s/ek5r5qgvripewdz/rabbitmq-qpid-jms-conn-created.PNG?dl=0
>
>
> Any help will be welcome.
>
> Regards.
>
> - WR
>


____
This email message is a private communication. The information transmitted, including attachments, is intended only for the person or entity to which it is addressed and may contain confidential, privileged, and/or proprietary material. Any review, duplication, retransmission, distribution, or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is unauthorized by the sender and is prohibited. If you have received this message in error, please contact the sender immediately by return email and delete the original message from all computer systems. Thank you.

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