Hi, Your specified a broker host as localhost in your connection URL. I suppose that your client application is not located on the same host as broker. Thus, the connection cannot be established and error is reported. You can replace the locahost with turtle.rmq.cloudamqp.com in your connection URL and try again.
Please, have a look at [1] for more details about Qpid connection URL format. Kind Regards, Alex [1] http://qpid.apache.org/releases/qpid-0.24/programming/book/QpidJNDI.html On 11 November 2013 23:35, beon2013 <ming.li.e...@gmail.com> wrote: > In my Java EE application, I want send and receive a message using a RabbitMQ > broker and a Qpid JMS client. > > > The information about RabbitMQ broker is as follow: > > Server: turtle.rmq.cloudamqp.com > User: tsikywzh > Password: Z_1x359XUuKfkcK0PoohUVBWlqXtxVh > AMQP URL: > amqp://tsikywzh:z_1x359xuukfkck0poohuvbwlqxt...@turtle.rmq.cloudamqp.com/tsikywzh > > > The code for send a message using the Qpid JMS client: > > public void sendMessage(){ > logger.log(Level.INFO, "Sending message {0}", messageText); > Properties properties = new Properties(); > > properties.load(SenderBean.class.getResourceAsStream("/websimplemessage.properties")); > Context context = new InitialContext(properties); > ConnectionFactory connectionFactory = (ConnectionFactory) > context.lookup("qpidConnectionfactory"); > Connection connection = connectionFactory.createConnection(); > connection.start(); > Session session = connection.createSession(false, > Session.AUTO_ACKNOWLEDGE); > Destination destination = (Destination) > context.lookup("topicExchange"); > MessageProducer messageProducer = > session.createProducer(destination); > String text = "Message from producer: " + messageText; > TextMessage message = session.createTextMessage(text); > messageProducer.send(message); > connection.close(); > context.close(); > } > Which uses this Apache Qpid JNDI Properties File websimplemessage.properties > : > > java.naming.factory.initial = > org.apache.qpid.jndi.PropertiesFileInitialContextFactory > connectionfactory.qpidConnectionfactory = > amqp://tsikywzh:z_1x359xuukfkck0poohuvbwlqxt...@turtle.rmq.cloudamqp.com/tsikywzh?brokerlist='tcp://localhost:5672' > destination.topicExchange = amq.topic > > Unfortunately, when I run the application, I get connection errors: > > SenderBean.sendMessage: Exception: javax.jms.JMSException: Error creating > connection: Connection refused > > I am sure RabbitMQ broker is work. Maybe the Qpid JNDI properties File is > not correct. > > How can I solve this error? Thanks > > > > -- > View this message in context: > http://apache-qpid-developers.2158895.n2.nabble.com/connection-refused-error-for-a-Java-EE-app-with-RabbitMQ-broker-Qpid-JMS-client-tp7590925.html > Sent from the Apache Qpid developers mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org > For additional commands, e-mail: dev-h...@qpid.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org