我希望能够将消息发送到远程 JBoss 服务器 (JBoss MQ)。
我可以在本地进行此操作,但在尝试远程操作时却遇到了困难。
谁能给我解释一下该怎么做吗? 有什么具体步骤需要采取吗?
[到目前为止我尝试过的]
我需要将消息发送到远程服务器的队列(运行“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.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 远程服务器)。
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
连接到远程队列有什么特殊要做吗?
最佳答案
您是否确认可以连接到该远程主机和端口,即 telnet 192.168.131.129 1299
?您的防火墙可能会阻止某些流量但允许 ping。
关于java - 将消息发布到远程 JMS 提供者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1796262/