not able to connect to JBOSS message queue frome remote machine.
kallmekunal Mar 3, 2014 6:08 AMHi ,
I am new to JBOSS.
I am trying to connect to MessageQueue.From a different machine.
i have written a sample code as :
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
// Create the initial context
Context ctx = new InitialContext(env);
// Lookup the JMS connection factory from the JBoss 5.1 object store
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Queue queue = (javax.jms.Queue)ctx.lookup("/queue/DLQ");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(queue);
TextMessage textMessage = session.createTextMessage();
textMessage.setText("Hello World");
System.out.println("Sending Message: " + textMessage.getText());
messageProducer.send(textMessage);
This code is working fine when i run it from the same machine on which jboss is running.
As per my understanding JBOSS doesnot listens from other machines by default.so i restarted it with run.bat -b 0.0.0.0
and then i try to connect it from a different machine with same code snippet.
but i am getting below exception:
Unable to connect to server using configuration org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=0-0-0-0
javax.jms.JMSException: Unable to connect to server using configuration org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=0-0-0-0
at org.hornetq.core.client.impl.FailoverManagerImpl.createSession(FailoverManagerImpl.java:375)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSessionInternal(ClientSessionFactoryImpl.java:1123)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSession(ClientSessionFactoryImpl.java:849)
at org.hornetq.jms.client.HornetQConnection.authorize(HornetQConnection.java:565)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:624)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:111)
at com.ericsson.mediation.jms.JMSClient.connect(JMSClient.java:75)
at com.ericsson.mediation.jms.JMSConnectionController.initPrimary(JMSConnectionController.java:226)
at com.ericsson.mediation.jms.JMSConnectionController.initConfig(JMSConnectionController.java:111)
at com.ericsson.mediation.jms.JMSJavaActivityValueRouter.<init>(JMSJavaActivityValueRouter.java:64)
Caused by: HornetQException[errorCode=2 message=Unable to connect to server using configuration org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=0-0-0-0]
... 11 more
Seems my machine running the client knows about the jboss and its somehow looking something on port 5445 and host 0-0-0-0.
Please help.