我尝试在Jboss EAP 6.3中构建的HornetQ和Jboss 4.2.2上托管的Jboss Messaging主题之间建立JMS桥。该桥在Jboss EAP 6.3端配置 - 在standalone.xml中,目的是收听本地HornetQ主题并发布到远程Jboss Messaging。为此,我尝试按照此处所述的建议https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/html/Migration_Guide/Configure_a_JMS_Bridge_to_Migrate_Existing_JMS_Messages_to_Enterprise_Application_Platform_6.html 目前,我将其配置如下:
<jms-bridge name="myBridge" module="org.jbossmessaging">
<source>
<connection-factory name="ConnectionFactory"/>
<destination name="jms/SourceTopic"/>
</source>
<target>
<connection-factory name="java:/ConnectionFactory"/>
<destination name="jms/TargetTopic"/>
<user>user</user>
<password>pass</password>
<context>
<property key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>
<property key="java.naming.provider.url" value="jnp://10.26.75.194:1099"/>
<property key="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
</context>
</target>
<quality-of-service>DUPLICATES_OK</quality-of-service>
<failure-retry-interval>500</failure-retry-interval>
<max-retries>1</max-retries>
<max-batch-size>500</max-batch-size>
<max-batch-time>500</max-batch-time>
<add-messageID-in-header>true</add-messageID-in-header>
</jms-bridge>
我创建了下一个模块:
<module xmlns="urn:jboss:module:1.1" name="org.jbossmessaging">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<!-- Insert resources required to connect to the source or target -->
<resource-root path="jnp-client-4.0.2.jar" />
<resource-root path="jboss-messaging.jar" />
</resources>
<dependencies>
<!-- Add the dependencies required by JMS Bridge code -->
<module name="javax.api" />
<module name="javax.jms.api" />
<module name="javax.transaction.api"/>
<!-- Add a dependency on the org.hornetq module since we send -->
<!-- messages to the HornetQ server embedded in the local EAP instance -->
<module name="org.hornetq" />
<module name="org.jboss.logging" />
</dependencies></module>
当我尝试启动Jboss时,我有下一个例外:
20:49:37,101 WARN [org.hornetq.jms.server] (ServerService Thread Pool -- 62) HQ122010: Failed to connect JMS Bridge: javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 10.26.75.194; nested exception is:
java.net.ConnectException: Connection timed out: connect]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:647) [jnpserver-3.2.3.jar:3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507) [jnpserver-3.2.3.jar:3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_40]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_40]
at org.hornetq.jms.bridge.impl.JNDIFactorySupport.createObject(JNDIFactorySupport.java:58) [hornetq-jms-server-2.3.21.Final-redhat-1.jar:2.3.21.Final-redhat-1]
at org.hornetq.jms.bridge.impl.JNDIDestinationFactory.createDestination(JNDIDestinationFactory.java:40) [hornetq-jms-server-2.3.21.Final-redhat-1.jar:2.3.21.Final-redhat-1]
at org.hornetq.jms.bridge.impl.JMSBridgeImpl.setupJMSObjects(JMSBridgeImpl.java:1236) [hornetq-jms-server-2.3.21.Final-redhat-1.jar:2.3.21.Final-redhat-1]
at org.hornetq.jms.bridge.impl.JMSBridgeImpl.start(JMSBridgeImpl.java:416) [hornetq-jms-server-2.3.21.Final-redhat-1.jar:2.3.21.Final-redhat-1]
at org.jboss.as.messaging.jms.bridge.JMSBridgeService.startBridge(JMSBridgeService.java:99)
at org.jboss.as.messaging.jms.bridge.JMSBridgeService$1.run(JMSBridgeService.java:78)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_40]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_40]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_40]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.rmi.ConnectException: Connection refused to host: 10.26.75.194; nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) [rt.jar:1.8.0_40]
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216) [rt.jar:1.8.0_40]
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202) [rt.jar:1.8.0_40]
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130) [rt.jar:1.8.0_40]
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) [jnpserver-3.2.3.jar:3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528) [jnpserver-3.2.3.jar:3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)]
... 13 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method) [rt.jar:1.8.0_40]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) [rt.jar:1.8.0_40]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) [rt.jar:1.8.0_40]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) [rt.jar:1.8.0_40]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) [rt.jar:1.8.0_40]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) [rt.jar:1.8.0_40]
at java.net.Socket.connect(Socket.java:589) [rt.jar:1.8.0_40]
at java.net.Socket.connect(Socket.java:538) [rt.jar:1.8.0_40]
at java.net.Socket.<init>(Socket.java:434) [rt.jar:1.8.0_40]
at java.net.Socket.<init>(Socket.java:211) [rt.jar:1.8.0_40]
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40) [rt.jar:1.8.0_40]
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148) [rt.jar:1.8.0_40]
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613) [rt.jar:1.8.0_40]
... 18 more
主机可用且端口已打开,因此配置中存在问题。我想在我创建的模块中。我没有找到合适的示例,因此我决定在模块中包含一个包含org.jnp.interfaces.NamingContextFactory
和jboss-messaging.jar的库。也许必须涉及别的东西?或者我可能错误配置了jmg-bridge本身?
如果您有任何想法,请提供协助)
答案 0 :(得分:2)
最后我解决了这个问题。而且,关键在于,正确的模块配置。所以下面是适合的module.xml(至少对于Jboss Messaging 1.4.2):
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.jbossmessaging">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<!-- Insert resources required to connect to the source or target -->
<resource-root path="jnp-client-4.0.2.jar"/>
<resource-root path="jboss-messaging.jar"/>
<resource-root path="jboss-aop-2.1.1.ga.jar"/>
<resource-root path="jboss-remoting.jar"/>
<resource-root path="jboss-common-4.2.3.jar"/>
<resource-root path="trove-1.0.2.jar"/>
<resource-root path="javassist.jar"/>
<resource-root path="jboss-mdr.jar"/>
<resource-root path="concurrent-1.3.4.jar"/>
<resource-root path="log4j-snmp-appender.jar"/>
<resource-root path="log4j.jar"/>
<resource-root path="jboss-serialization.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.jms.api"/>
<module name="javax.transaction.api"/>
<module name="org.hornetq"/>
<module name="org.jboss.common-core"/>
</dependencies>
</module>
这些配置都是针对两个方向进行测试的(我已经再制作了一个听Jboss Messaging并发布到HornetQ的桥接器)并且看起来都很好