集群消息(HornetQ)无法启动

时间:2014-07-28 14:48:05

标签: java-ee jms wildfly wildfly-8 hornetq

我正在运行Wildfly 8.1,并尝试使用standalone-full-ha.xml配置启动并运行独立(非域)群集。我已经关注了几个集群指南,包括这个指南,但我的成功有限。如果我使用standalone-ha.xml配置,我可以使集群工作,但此配置不包括用于JMS消息传递的HornetQ。但是,当我尝试standalone-full-ha.xml配置时,我在日志中看到以下内容:

10:40:33,079 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 60) HQ221006: Waiting to obtain live lock
10:40:33,112 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 60) HQ221013: Using NIO Journal
10:40:33,168 INFO  [io.netty.util.internal.PlatformDependent] (ServerService Thread Pool -- 60) Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system unstability.
10:40:33,206 INFO  [org.jboss.as.jacorb] (MSC service thread 1-8) JBAS016328: CORBA Naming Service started
10:40:33,243 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 60) HQ221043: Adding protocol support CORE
10:40:33,246 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
10:40:33,251 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 60) HQ221043: Adding protocol support AMQP
10:40:33,255 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 60) HQ221043: Adding protocol support STOMP
10:40:33,478 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /Volumes/Untitled/Servers/wildfly-8.1.0.Final/standalone/deployments
10:40:33,589 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.4.Final
10:40:33,620 INFO  [org.hornetq.core.server] (Thread-0 (HornetQ-server-HornetQServerImpl::serverUUID=a8a0aba8-1664-11e4-a805-3703f1c18bf5-370179839)) HQ221031: backup announced
10:40:38,301 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 60) HQ221034: Waiting to obtain live lock

它只是挂在"等待获得实时锁定"信息。服务器永远不会指示它已启动,我无法访问管理控制台。这是我一直在尝试的......

  1. 获取Wildfly 8.1发行版并将其解压缩
  2. 通过发出命令./standalone.sh -c standalone-full-ha.xml -Djboss.node.name=nodeA
  3. 启动节点1
  4. 通过发出命令./standalone.sh -c standalone-full-ha.xml -Djboss.node.name=nodeB -Djboss.socket.binding.port-offset=100
  5. 启动节点2

    但是,当我这样做时,我在上面描述的日志中看到了消息,并且服务器永远不会完成启动。

    我做错了吗?我需要采取其他步骤来使群集消息传递和Wildfly按预期工作吗?

2 个答案:

答案 0 :(得分:2)

您需要配置JMS群集。尝试将以下配置添加到独立配置中:

<subsystem xmlns="urn:jboss:domain:messaging:2.0">
    <hornetq-server>
        <cluster-user>username</cluster-user>
        <cluster-password>${jboss.messaging.cluster.password:changeme}</cluster-password>
        <journal-file-size>102400</journal-file-size>

        <connectors>
            <http-connector name="http-connector" socket-binding="http">
                <param key="http-upgrade-endpoint" value="http-acceptor"/>
            </http-connector>
            <http-connector name="http-connector-throughput" socket-binding="http">
                <param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>
                <param key="batch-delay" value="50"/>
            </http-connector>
            <in-vm-connector name="in-vm" server-id="0"/>
        </connectors>

        <acceptors>
            <http-acceptor http-listener="default" name="http-acceptor"/>
            <http-acceptor http-listener="default" name="http-acceptor-throughput">
                <param key="batch-delay" value="50"/>
                <param key="direct-deliver" value="false"/>
            </http-acceptor>
            <in-vm-acceptor name="in-vm" server-id="0"/>
        </acceptors>

        <broadcast-groups>
            <broadcast-group name="bg-group1">
                <socket-binding>messaging-group</socket-binding>
                <connector-ref>
                    http-connector
                </connector-ref>
            </broadcast-group>
        </broadcast-groups>

        <discovery-groups>
            <discovery-group name="dg-group1">
                <socket-binding>messaging-group</socket-binding>
            </discovery-group>
        </discovery-groups>

        <cluster-connections>
            <cluster-connection name="my-cluster">
                <address>jms</address>
                <connector-ref>http-connector</connector-ref>
                <discovery-group-ref discovery-group-name="dg-group1"/>
            </cluster-connection>
        </cluster-connections>

        <security-settings>
            <security-setting match="#">
                <permission type="send" roles="guest"/>
                <permission type="consume" roles="guest"/>
                <permission type="createNonDurableQueue" roles="guest"/>
                <permission type="deleteNonDurableQueue" roles="guest"/>
            </security-setting>
        </security-settings>

        <address-settings>
            <address-setting match="#">
                <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                <max-size-bytes>10485760</max-size-bytes>
                <page-size-bytes>2097152</page-size-bytes>
                <message-counter-history-day-limit>10</message-counter-history-day-limit>
                <redistribution-delay>1000</redistribution-delay>
            </address-setting>
        </address-settings>

        <jms-connection-factories>
            <connection-factory name="InVmConnectionFactory">
                <connectors>
                    <connector-ref connector-name="in-vm"/>
                </connectors>
                <entries>
                    <entry name="java:/ConnectionFactory"/>
                </entries>
            </connection-factory>
            <connection-factory name="RemoteConnectionFactory">
                <connectors>
                    <connector-ref connector-name="http-connector"/>
                </connectors>
                <entries>
                    <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                </entries>
                <ha>true</ha>
                <block-on-acknowledge>true</block-on-acknowledge>
                <reconnect-attempts>-1</reconnect-attempts>
            </connection-factory>
            <connection-factory name="TopicConnectionFactory">
                <connectors>
                    <connector-ref connector-name="in-vm"/>
                </connectors>
                <entries>
                    <entry name="jms/TopicConnectionFactory"/>
                </entries>
                <compress-large-messages>false</compress-large-messages>
                <failover-on-initial-connection>false</failover-on-initial-connection>
                <use-global-pools>true</use-global-pools>
            </connection-factory>
            <pooled-connection-factory name="hornetq-ra">
                <transaction mode="xa"/>
                <connectors>
                    <connector-ref connector-name="in-vm"/>
                </connectors>
                <entries>
                    <entry name="java:/JmsXA"/>
                    <entry name="java:jboss/DefaultJMSConnectionFactory"/>
                </entries>
            </pooled-connection-factory>
        </jms-connection-factories>

        <jms-destinations>
            <jms-queue name="ExpiryQueue">
                <entry name="java:/jms/queue/ExpiryQueue"/>
            </jms-queue>
            <jms-queue name="DLQ">
                <entry name="java:/jms/queue/DLQ"/>
            </jms-queue>
            <jms-topic name="Topic">
                <entry name="jms/Topic"/>
            </jms-topic>
        </jms-destinations>
    </hornetq-server>
</subsystem>

和套接字绑定:

<socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/>

您需要根据应用程序更改主题/连接工厂名称和用户凭据。在上面的示例中,您还必须更改应用程序的消息传递配置以连接/侦听多播端口(默认情况下为231.7.7.7:9876)。

答案 1 :(得分:0)

看一下手册 http://docs.jboss.org/hornetq/2.4.0.Final/docs/user-manual/html/ha.html

还必须将NodeB配置为备份服务器:

<hornetq-server> <backup>true</backup> ... </hornetq-server>