JMS消息到远程服务器 [英] JMS message to remote server

查看:156
本文介绍了JMS消息到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将消息发送到远程服务器的队列(运行JBoss MQ),以便它可以处理消息并对其进行操作。

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");

但运行以上代码时出现异常:
(尽管我可以ping远程服务器。)

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 ?

推荐答案

我通过使用以下进程参数重新启动JBoss服务器来解决问题:

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

-b 0.0.0.0

-b 0.0.0.0

JBoss服务器默认启动时只允许本地连接。通过使用前面提到的参数启动它,您可以指示它接受远程连接。

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.

这篇关于JMS消息到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆