[英]JMS message to remote server
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. 我需要将消息发送到远程服务器的队列(运行“ JBoss MQ”),以便它可以处理消息并对其执行操作。
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). 但是运行上面的代码时出现异常:(即使我可以ping通远程服务器)。
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 ? 连接到远程队列有什么特别的事情吗?
您使用的IP地址不正确:192.168.1.131.129有5个数字,只能有4个。
I solved the problem by restarting my JBoss server with the following process arguments : 我通过使用以下过程参数重启JBoss服务器来解决了这个问题:
-b 0.0.0.0 -b 0.0.0.0
the JBoss server is started by default to only allow local connections. 默认情况下,JBoss服务器已启动,仅允许本地连接。 by starting it with the afore mentionned arguments, you instruct it to accept remote connections.
通过使用前面提到的参数启动它,可以指示它接受远程连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.