编程语言
首页 > 编程语言> > java – 设置HornetQ嵌入式远程示例

java – 设置HornetQ嵌入式远程示例

作者:互联网

我在hornetq-2.3.0.Final jar下名为Embedded-Remote的核心文件夹下设置示例有一些麻烦,我试图在同一局域网中使用这两台计算机的“远程环境”中运行示例,如果我运行这两个类没有更改同一台计算机中的任何内容“EmbeddedRemotExample.java”运行正常,但由于此示例缺少配置文件,因此我不确定如何将此类设置为连接到另一台计算机上运行的服务器.阅读api我发现这是一个有效的代码:

`

     HashMap map = new HashMap();
     map.put("host", "192.168.XXX.XXX");
     map.put("port", 5445);
     ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(
         new TransportConfiguration(NettyConnectorFactory.class.getName(),map));
     ClientSessionFactory sf = serverLocator.createSessionFactory();` 

但这会产生下一个例外

HornetQException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:852)
at org.hornetq.core.example.EmbeddedRemoteExample.main(EmbeddedRemoteExample.java:49)`

我怎么能设置这个具体的例子?

在一台计算机中:org.hornetq.core.example.EmbeddedServer

在另一个:org.hornetq.core.example.EmbeddedRemoteExample

解决方法:

您需要在EmbeddedServer.java中将相同的配置添加到服务器的Acceptor.默认情况下,它将设置为localhost.

我认为该示例需要清理代码:

https://github.com/hornetq/hornetq/pull/1062

此特定提交将明确您需要更改的内容:

https://github.com/FranciscoBorges/hornetq/commit/fbed7e8394c843e4528df90d4c2ef155a7d032c0

标签:java,jms,hornetq
来源: https://codeday.me/bug/20190620/1244015.html