1

我们在 core-bridge 和 hornetq 面临以下问题,希望能提供任何帮助。

情况:

我们有独立的 hornetq 服务器,比如 QSA,和另一个 hornetq 服务器,比如 QSB。目标是通过将消息发送到 QSA/队列上的队列的方式桥接队列

Hornetq 服务器都是 hornetq-2.4.0.Final 和运行的独立,非集群。

在 QSA 上,我们有两个相关的队列:

  • 队列/数据集线器/交换

  • 队列/datahub/switchedinquiry-send

在 QSA 上,我们还有两个相关的队列:

  • 队列/智能控制/交换查询

  • 队列/智能控制/交换发送

桥现在应该如下工作:

  • QSA:/queue/datahub/switchedinquiry-send --> Bridge--> QSB:queue/smartcontrol/switchedinquiry

  • QSB:queue/smartcontrol/switched-send --> Bridge--> QSA:qeue/datahub/switched

问题:

当 QSA 和 QSA 在同一主机上运行并使用 IP 或环回 (localhost) 进行配置时,一切正常。

**但我们想要的是,QSA 和 QSB 使用不同的 ip 在不同的主机上运行。出现问题的地方:**

HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119013: Timed out waiting to receive cluster topology. Group:null]


16 Jul 2014 12:09:16,622 DEBUG [Thread-20 (HornetQ-server-HornetQServerImpl::serverUUID=6cdc0a86-083b-11e4-84ef-c3d4fbb03c17-103207534)] org.hornetq.core.server.cluster.impl.BridgeImpl:977 - Bridge BridgeImpl@65719a42 [name=inquiry.bridge, queue=QueueImpl[name=jms.queue.datahub.switchedinquiry-send, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=6cdc0a86-083b-11e4-84ef-c3d4fbb03c17]]@7c25984b targetConnector=ServerLocatorImpl (identity=Bridge inquiry.bridge) [initialConnectors=[TransportConfiguration(name=remote-connector, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5446&host=10-254-8-1], discoveryGroupConfiguration=null]] is unable to connect to destination. Retrying: HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119013: Timed out waiting to receive cluster topology. Group:null]
    at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:950) [hornetq-core-client.jar:]
    at org.hornetq.core.server.cluster.impl.BridgeImpl.createSessionFactory(BridgeImpl.java:820) [hornetq-server.jar:]
    at org.hornetq.core.server.cluster.impl.BridgeImpl.connect(BridgeImpl.java:890) [hornetq-server.jar:]
    at org.hornetq.core.server.cluster.impl.BridgeImpl$ConnectRunnable.run(BridgeImpl.java:1108) [hornetq-server.jar:]
    at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:107) [hornetq-core-client.jar:]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

使用标准 jms-bridge 或多或少会发生相同的异常,即使 stacktrac 有点长:

使用标准 jms-bridge 似乎存在同样的问题。Thje Stacktrace 有点长,但总而言之,它是一个基本的例外:

HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119013: Timed out waiting to receive cluster topology. Group:null]

16 Jul 2014 16:51:25,179 WARN  [main] org.hornetq.jms.bridge.impl.JMSBridgeImpl:1357 - HQ122010: Failed to connect JMS Bridge: javax.jms.JMSException: Failed to create session factory
    at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:676) [hornetq-jms-client.jar:]
    at org.hornetq.jms.client.HornetQConnectionFactory.createXAConnection(HornetQConnectionFactory.java:208) [hornetq-jms-client.jar:]
    at org.hornetq.jms.client.HornetQConnectionFactory.createXAConnection(HornetQConnectionFactory.java:203) [hornetq-jms-client.jar:]
    at org.hornetq.jms.bridge.impl.JMSBridgeImpl.createConnection(JMSBridgeImpl.java:1104) [hornetq-jms-server.jar:]
    at org.hornetq.jms.bridge.impl.JMSBridgeImpl.setupJMSObjects(JMSBridgeImpl.java:1310) [hornetq-jms-server.jar:]
    at org.hornetq.jms.bridge.impl.JMSBridgeImpl.start(JMSBridgeImpl.java:415) [hornetq-jms-server.jar:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]
    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]
    at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59) [jboss-mc.jar:]
    at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150) [jboss-mc.jar:]
    at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774) [jboss-mc.jar:]
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:319) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:297) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:130) [jboss-mc.jar:]
    at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96) [jboss-mc.jar:]
    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:236) [hornetq-bootstrap.jar:]
    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:206) [hornetq-bootstrap.jar:]
    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.bootstrap(HornetQBootstrapServer.java:154) [hornetq-bootstrap.jar:]
    at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:83) [jboss-mc.jar:]
    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.run(HornetQBootstrapServer.java:115) [hornetq-bootstrap.jar:]
    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.main(HornetQBootstrapServer.java:69) [hornetq-bootstrap.jar:]
Caused by: HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119013: Timed out waiting to receive cluster topology. Group:null]
    at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:950) [hornetq-core-client.jar:]
    at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:672) [hornetq-jms-client.jar:]
    ... 39 more

问题

1.) 为什么这个配置会运行,如果两个 hornetq 服务器都运行在同一台机器上,但在不同的机器上运行时却没有。2.)我们如何使用 hornetq 实现所需的行为(在 Situation 中描述)。

配置:

使用了以下配置文件。如果两个 hornetq 在同一台机器上运行,则此处提供的配置有效。但是,如果我们将 ip 改编为一台服务器到另一台机器。出现描述的问题。

QSA

hornetq-beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
        <!-- MBean server -->
        <bean name="MBeanServer" class="javax.management.MBeanServer">
                <constructor factoryClass="java.lang.management.ManagementFactory"
                        factoryMethod="getPlatformMBeanServer" />
        </bean>
        <!-- The core configuration -->
        <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration">
        </bean>
        <!-- The security manager -->
        <bean name="HornetQSecurityManager"
                class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
                <start ignored="true" />
                <stop ignored="true" />
        </bean>
        <!-- The core server -->
        <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">
                <constructor>
                        <parameter>
                                <inject bean="Configuration" />
                        </parameter>
                        <parameter>
                                <inject bean="MBeanServer" />
                        </parameter>
                        <parameter>
                                <inject bean="HornetQSecurityManager" />
                        </parameter>
                </constructor>
                <start ignored="true" />
                <stop ignored="true" />
        </bean>
        <!-- The Stand alone server that controls the jndi server -->
        <bean name="StandaloneServer" class="org.hornetq.jms.server.impl.StandaloneNamingServer">
                <constructor>
                        <parameter>
                                <inject bean="HornetQServer" />
                        </parameter>
                </constructor>
                <property name="port">${jnp.port:41099}</property>
                <property name="bindAddress">${jnp.host:159.232.217.119}</property>
                <property name="rmiPort">${jnp.rmiPort:41098}</property>
                <property name="rmiBindAddress">${jnp.host:159.232.217.119}</property>
        </bean>
        <!-- The JMS server -->
        <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
                <constructor>
                        <parameter>
                                <inject bean="HornetQServer" />
                        </parameter>
                </constructor>
        </bean>
</deployment>

hornetq-configuration.xml

<configuration xmlns="urn:hornetq"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:hornetq/schema/hornetq-configuration.xsd">
        <paging-directory>${data.dir:../data}/paging_dh</paging-directory>
        <bindings-directory>${data.dir:../data}/bindings_dh
        </bindings-directory>
        <journal-directory>${data.dir:../data}/journal_dh</journal-directory>
        <journal-min-files>10</journal-min-files>
        <large-messages-directory>${data.dir:../data}/large-messages_dh
        </large-messages-directory>
        <!-- Connectors -->
        <connectors>
                <connector name="netty-connector">
                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory
                        </factory-class>
                        <param key="port" value="5445" />
                        <param key="host" value="159.232.217.119" />
                </connector>
                <!-- Connector to the other node -->
                <connector name="remote-connector">
                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory
                        </factory-class>
                        <param key="port" value="5446" />
                        <param key="host" value="159.232.217.119" />
                        <!-- <param key="host" value="10.254.8.1"/> -->
                </connector>
        </connectors>
        <!-- Acceptors -->
        <acceptors>
                <acceptor name="netty-acceptor">
                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory
                        </factory-class>
                        <param key="port" value="5445" />
                        <param key="host" value="159.232.217.119" />
                </acceptor>
        </acceptors>
        <queues>
                <queue name="jms.queue.smartcontrol.switchedinquiry">
                        <address>jms.queue.smartcontrol.switchedinquiry</address>
                        <durable>true</durable>
                </queue>
                <queue name="jms.queue.datahub.switchedinquiry-send">
                        <address>jms.queue.datahub.switchedinquiry-send</address>
                        <durable>true</durable>
                </queue>
        </queues>
        <!-- We set-up a bridge that forwards from a queue on this node to an address
                on another node. We specify a filter with the bridge, and a transformer too.
                The filter and transformer are optional -->
        <bridges>
                <bridge name="inquiry.bridge">
                        <queue-name>jms.queue.datahub.switchedinquiry-send</queue-name>
                        <forwarding-address>jms.queue.smartcontrol.switchedinquiry
                        </forwarding-address>
                        <reconnect-attempts>-1</reconnect-attempts>
                        <static-connectors>
                                <connector-ref>remote-connector</connector-ref>
                        </static-connectors>
                </bridge>
        </bridges>
        <security-settings>
                <!--security for example queue -->
                <security-setting match="jms.queue.#">
                        <permission type="createDurableQueue" roles="guest" />
                        <permission type="deleteDurableQueue" roles="guest" />
                        <permission type="createNonDurableQueue" roles="guest" />
                        <permission type="deleteNonDurableQueue" roles="guest" />
                        <permission type="consume" roles="guest" />
                        <permission type="send" roles="guest" />
                </security-setting>
        </security-settings>
        <address-settings>
                <address-setting match="jms.queue.smartcontrol.switchedinquiry">
                        <dead-letter-address>jms.queue.smartcontrol.switchedinquiryDLQ
                        </dead-letter-address>
                        <max-size-bytes>262144000</max-size-bytes>
                        <page-size-bytes>10485760</page-size-bytes>
                        <address-full-policy>PAGE</address-full-policy>
                </address-setting>
        </address-settings>
</configuration>

hornetq-jms.xml

<configuration xmlns="urn:hornetq"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
        <connection-factory name="ConnectionFactory">
                <connectors>
                        <connector-ref connector-name="netty-connector" />
                </connectors>
                <entries>
                        <entry name="ConnectionFactory" />
                </entries>
        </connection-factory>
        <queue name="datahub.switched">
                <entry name="queue/datahub/switched" />
        </queue>
        <queue name="datahub.switchedinquiry-send">
                <entry name="queue/datahub/switchedinquiry-send" />
        </queue>
</configuration>

QSB

hornetq-beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
        <!-- MBean server -->
        <bean name="MBeanServer" class="javax.management.MBeanServer">
                <constructor factoryClass="java.lang.management.ManagementFactory"
                        factoryMethod="getPlatformMBeanServer" />
        </bean>
        <!-- The core configuration -->
        <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration">
        </bean>
        <!-- The security manager -->
        <bean name="HornetQSecurityManager"
                class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
                <start ignored="true" />
                <stop ignored="true" />
        </bean>
        <!-- The core server -->
        <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">
                <constructor>
                        <parameter>
                                <inject bean="Configuration" />
                        </parameter>
                        <parameter>
                                <inject bean="MBeanServer" />
                        </parameter>
                        <parameter>
                                <inject bean="HornetQSecurityManager" />
                        </parameter>
                </constructor>
                <start ignored="true" />
                <stop ignored="true" />
        </bean>
        <!-- The Stand alone server that controls the jndi server -->
        <bean name="StandaloneServer" class="org.hornetq.jms.server.impl.StandaloneNamingServer">
                <constructor>
                        <parameter>
                                <inject bean="HornetQServer" />
                        </parameter>
                </constructor>
                <property name="port">${jnp.port:1099}</property>
                <property name="bindAddress">${jnp.host:159.232.217.119}</property>
                <property name="rmiPort">${jnp.rmiPort:1098}</property>
                <property name="rmiBindAddress">${jnp.host:159.232.217.119}</property>
        </bean>
        <!-- The JMS server -->
        <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
                <constructor>
                        <parameter>
                                <inject bean="HornetQServer" />
                        </parameter>
                </constructor>
        </bean>
</deployment>

hornetq-configuration.xml

<configuration xmlns="urn:hornetq"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
        <paging-directory>${data.dir:../data}/paging_rsa</paging-directory>
        <bindings-directory>${data.dir:../data}/bindings_rsa
        </bindings-directory>
        <journal-directory>${data.dir:../data}/journal_rsa</journal-directory>
        <journal-min-files>10</journal-min-files>
        <large-messages-directory>${data.dir:../data}/large-messages_rsa
        </large-messages-directory>
        <connectors>
                <connector name="netty-connector">
                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory
                        </factory-class>
                        <param key="port" value="5446" />
                        <param key="host" value="159.232.217.119" />
                </connector>
                <!-- Connector to the other node -->
                <connector name="remote-connector-bridge">
                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory
                        </factory-class>
                        <param key="port" value="5445" />
                        <!-- <param key="host" value="159.232.3.62" /> -->
                        <param key="host" value="159.232.217.119" />
                </connector>
        </connectors>
        <!-- Acceptors -->
        <acceptors>
                <acceptor name="netty-acceptor">
                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory
                        </factory-class>
                        <param key="port" value="5446" />
                        <param key="host" value="159.232.217.119" />
                </acceptor>
        </acceptors>
        <queues>
                <!-- rsa queues -->
                <queue name="jms.queue.smartcontrol.switched-send">
                        <address>jms.queue.smartcontrol.switched-send</address>
                        <durable>true</durable>
                </queue>
                <!-- datahub queues -->
                <queue name="jms.queue.datahub.switched">
                        <address>jms.queue.datahub.switched</address>
                        <durable>true</durable>
                </queue>
        </queues>
        <!-- We set-up a bridge that forwards from a queue on this node to an address
                on another node. We specify a filter with the bridge, and a transformer too.
                The filter and transformer are optional -->
        <bridges>
                <bridge name="switched.bridge">
                        <queue-name>jms.queue.smartcontrol.switched-send</queue-name>
                        <forwarding-address>jms.queue.datahub.switched</forwarding-address>
                        <reconnect-attempts>-1</reconnect-attempts>
                        <static-connectors>
                                <connector-ref>remote-connector-bridge</connector-ref>
                        </static-connectors>
                </bridge>
        </bridges>
        <security-settings>
                <!--security for example queue -->
                <security-setting match="jms.queue.#">
                        <permission type="createDurableQueue" roles="guest" />
                        <permission type="deleteDurableQueue" roles="guest" />
                        <permission type="createNonDurableQueue" roles="guest" />
                        <permission type="deleteNonDurableQueue" roles="guest" />
                        <permission type="consume" roles="guest" />
                        <permission type="send" roles="guest" />
                </security-setting>
        </security-settings>
        <address-settings>
                <address-setting match="jms.queue.datahub.switched">
                        <dead-letter-address>jms.queue.datahub.switchedDLQ
                        </dead-letter-address>
                        <max-size-bytes>262144000</max-size-bytes>
                        <page-size-bytes>10485760</page-size-bytes>
                        <address-full-policy>PAGE</address-full-policy>
                </address-setting>
        </address-settings>
</configuration>

hornetq-jms.xml

<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
        <connection-factory name="ConnectionFactory">
                <connectors>
                        <connector-ref connector-name="netty-connector" />
                </connectors>
                <entries>
                        <entry name="ConnectionFactory" />
                </entries>
        </connection-factory>
        <queue name="smartcontrol.switched-send">
                <entry name="queue/smartcontrol/switched-send" />
        </queue>
        <queue name="smartcontrol.switchedinquiry">
                <entry name="queue/smartcontrol/switchedinquiry" />
        </queue>
</configuration>
4

0 回答 0