qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mansour Al Akeel <mansour.alak...@gmail.com>
Subject Connecting to RabbitMQ using QPid client
Date Wed, 10 Jun 2015 13:29:56 GMT
Hello,

 I am a bit confused by the compatibily issues between different
versions of the AMPQ, and lost in the documentation.

First thing, as far as I know, AMQP is not JMS. There's a lot of
examples QPid about JMS, which led me to include that in QPid, JMS is
compatible with AMQP. Is this conclusiong correct ?
Is it documented some where ??


We have two components "QPid Proton" and "QPid JMS". Both are clients
for AMQP. QPid JMS is built on Proton.
Which one do I use ?

Additionally, I am not sure about what mvn depencies to use with what.
Then comes the URL and the initial factory part. Looking at the
examples, was not a lot of help, as I am testing agains RabbitMQ, and
don't know when I am hitting an issue, if it's compatability or I am
doing something wrong.

Here's the initial factory options we have,


java.naming.factory.initial = org.apache.qpid.jms.jndi.JmsInitialContextFactory
java.naming.factory.initial =
org.apache.qpid.jndi.PropertiesFileInitialContextFactory
java.naming.factory.initial =
org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory

Then the URL format,
connectionfactory.localhost =
amqp://guest:guest@localhost:5672?clientid=test-client&remote-host=default
connectionfactory.localhost = amqp://guest:guest@localhost:5672
connectionfactory.localhost = amqp://localhost:5672

I have read these pages, but still lost:

https://cwiki.apache.org/confluence/display/qpid/AMQP+compatibility
https://www.rabbitmq.com/interoperability.html

Now, my issue is connecting using QPid client to both RabbitMQ and
QPid broker 0.32

I am just doing the simple HelloWord example:

Here's my jndi:
java.naming.factory.initial = org.apache.qpid.jms.jndi.JmsInitialContextFactory
connectionfactory.localhost = amqp://localhost:5672
queue.myQueue = git-repo-name

maven:
        <dependency>
            <groupId>org.apache.qpid</groupId>
            <artifactId>qpid-jms-client</artifactId>
            <version>0.2.0</version>
        </dependency>

Java:
            Context context = new InitialContext();
            ConnectionFactory factory = (ConnectionFactory)
context.lookup("localhost");
            Destination queue = (Destination) context.lookup("myQueue");
            Connection connection = factory.createConnection(USER, PASSWORD);
            connection.setExceptionListener(new MyExceptionListener());
            connection.start();
            Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);


The error on the client when connecting to QPid:

2015-06-10 17:22:04,483 [localhost:5672]] - DEBUG AmqpAbstractResource
          - AmqpSession { ID:localhost-48465-1433942523956-0:1:1 } is
now open:
2015-06-10 17:22:04,488 [localhost:5672]] - DEBUG AmqpSession
          - Creating AmqpFixedProducer for: git-repo-name
2015-06-10 17:22:04,495 [localhost:5672]] - TRACE NettyTcpTransport
          - Attempted write of: 253 bytes
2015-06-10 17:22:07,498 [ntLoopGroup-2-1] - TRACE NettyTcpTransport
          - Exception on channel! Channel is [id: 0x6ca00e8f,
/127.0.0.1:44497 => localhost/127.0.0.1:5672]
2015-06-10 17:22:07,499 [localhost:5672]] - INFO  AmqpProvider
          - Transport failed: Connection reset by peer
2015-06-10 17:22:07,500 [ntLoopGroup-2-1] - TRACE NettyTcpTransport
          - Channel has gone inactive! Channel is [id: 0x6ca00e8f,
/127.0.0.1:44497 :> localhost/127.0.0.1:5672]
Connection ExceptionListener fired, exiting.
2015-06-10 17:22:07,501 [localhost:5672]] - DEBUG AmqpProvider
          - Transport connection remotely closed
javax.jms.JMSException: Connection reset by peer
    at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:60)
    at org.apache.qpid.jms.JmsConnection.onAsyncException(JmsConnection.java:1169)
    at org.apache.qpid.jms.JmsConnection.onConnectionFailure(JmsConnection.java:1085)
    at org.apache.qpid.jms.provider.amqp.AmqpProvider.fireProviderException(AmqpProvider.java:832)
    at org.apache.qpid.jms.provider.amqp.AmqpProvider$17.run(AmqpProvider.java:688)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Connection reset by peer
    at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
    at sun.nio.ch.IOUtil.read(IOUtil.java:197)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
    at io.netty.buffer.UnpooledHeapByteBuf.setBytes(UnpooledHeapByteBuf.java:256)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:871)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:208)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:108)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:494)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:461)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:378)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:350)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
    ... 1 more



When connecting to rabbitMQ I am getting this client error:

015-06-10 12:04:54,395 [ntLoopGroup-2-1] - TRACE NettyTcpTransport
         - Channel has gone inactive! Channel is [id: 0xc1361df3,
/127.0.0.1:36720 :> localhost/127.0.0.1:5672]
Connection ExceptionListener fired, exiting.
2015-06-10 12:04:54,397 [localhost:5672]] - DEBUG AmqpProvider
          - Transport connection remotely closed
javax.jms.JMSException: Connection reset by peer
    at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:60)
    at org.apache.qpid.jms.JmsConnection.onAsyncException(JmsConnection.java:1169)
    at org.apache.qpid.jms.JmsConnection.onConnectionFailure(JmsConnection.java:1085)
    at org.apache.qpid.jms.provider.amqp.AmqpProvider.fireProviderException(AmqpProvider.java:832)
    at org.apache.qpid.jms.provider.amqp.AmqpProvider$17.run(AmqpProvider.java:688)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Connection reset by peer
    at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
    at sun.nio.ch.IOUtil.read(IOUtil.java:197)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
    at io.netty.buffer.UnpooledHeapByteBuf.setBytes(UnpooledHeapByteBuf.java:256)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:871)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:208)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:108)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:494)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:461)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:378)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:350)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
    ... 1 more

Please note that with rabbitMq, I am able to connect and send messages
from Python using Pika:

credentials = pika.PlainCredentials('guest', 'guest')
parameters = pika.ConnectionParameters('localhost' , 5672 , '/'  , credentials )
connection = pika.BlockingConnection( parameters )
channel = connection.channel()
#channel.queue_declare(queue='git-repo-name')
for line in out.readlines():
    channel.basic_publish(exchange='', routing_key='git-repo-name',
body=line.rstrip() )
connection.close()


Any help is highly appreciated.

Thank you

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


Mime
View raw message