How to configure Apache QPID to work with RabbitMQ?
Hello I will be happy to understand how can I write simple Java standalone program which sends and receives messages to RabbitMQ using Apache QPID jms client.
How can I create an initial context from QPID and then lookup destination from RabbitMQ?
I searched a lot in internet but I was not able to find any solution which helps me to get better understanding on creating the connection between this two.
I believe this should be possible due to the fact that both RabbitMQ and QPID are using AMQP protocol.
I tried with to create the Context with the following jndi.properties:
java.naming.factory.initial = org.apache.qpid.jms.jndi.JmsInitialContextFactory connectionfactory.myFactoryLookup = amqp://:5672 queue.myQueueLookup = queue
And the following code:
Context context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
Destination queue = (Destination) context.lookup("myQueueLookup");
Connection connection = factory.createConnection(USER, PASSWORD);
connection.setExceptionListener(new MyExceptionListener());
connection.start();
But I am getting an exception:
javax.jms.JMSException: An existing connection was forcibly closed by the remote host
at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:66)
at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:88)
at org.apache.qpid.jms.JmsConnection.createResource(JmsConnection.java:548)
at org.apache.qpid.jms.JmsConnection.createResource(JmsConnection.java:532)
at org.apache.qpid.jms.JmsConnection.connect(JmsConnection.java:447)
at org.apache.qpid.jms.JmsConnection.start(JmsConnection.java:301)
at com.test.Sender.main(Sender.java:36)
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
Do somebody have an idea what could be the reason and and advise if there is something wrong with the code ???
Thanks in advance!
链接地址: http://www.djcxy.com/p/34126.html