JMS message to remote server

眉间皱痕 提交于 2020-01-07 08:18:58

问题


I need to send a message to a remote server's queue (running "JBoss MQ") so that it can process the message and act on it.

    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
    properties.put(Context.PROVIDER_URL, "jnp://192.168.1.131.129:1299");
    InitialContext jndiContext = new InitialContext(properties);

    //[2] Look up connection factory and queue.
    ConnectionFactory connectionFactory = (ConnectionFactory)jndiContext.lookup("UIL2XAConnectionFactory");
    Queue queue = (Queue)jndiContext.lookup("Queue/DataTransferQueue");

but I get an exception when running the above code : (even though, I can ping the remote server).

javax.naming.CommunicationException: Could not obtain connection to any of these urls: 192.168.1.131.129:1299 and 
discovery failed with error: javax.naming.CommunicationException: 
Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] 
[Root exception is javax.naming.CommunicationException: Failed to connect to server 192.168.1.131.129:1299 

Is there anything special to do to connect to a remote queue ?


回答1:


The IP address you're using is incorrect: 192.168.1.131.129 has 5 numbers, it should only have 4.




回答2:


I solved the problem by restarting my JBoss server with the following process arguments :

-b 0.0.0.0

the JBoss server is started by default to only allow local connections. by starting it with the afore mentionned arguments, you instruct it to accept remote connections.



来源:https://stackoverflow.com/questions/1795983/jms-message-to-remote-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!