Search code examples
jakarta-eejmswildflywildfly-8hornetq

Clustered Messaging (HornetQ) unable to start


I'm running Wildfly 8.1, and am trying to get a standalone (non-domain) cluster up and running using the standalone-full-ha.xml configuration. I've followed several clustering guides, including this one, but am having limited success. I can get the cluster working if I use the standalone-ha.xml configuration, but this configuration does not include HornetQ for JMS messaging. When I attempt the standalone-full-ha.xml configuration, however, I see the following in the logs:

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

It just hangs at the "Waiting to obtain live lock" message. The server never indicates that it is started, and I am unable to access the administration console. Here is what I've been trying...

  1. Get a stock Wildfly 8.1 distribution and unpack it
  2. Start node 1 by issuing the command ./standalone.sh -c standalone-full-ha.xml -Djboss.node.name=nodeA
  3. Start node 2 by issuing the command ./standalone.sh -c standalone-full-ha.xml -Djboss.node.name=nodeB -Djboss.socket.binding.port-offset=100

When I do this, however, I see the message in the log that I described above, and the server never completes startup.

Am I doing something wrong? Are there additional steps I need to take to get clustered messaging and Wildfly to work as expected?


Solution

  • You need to configure JMS clustering. Try adding the following configuration to your standalone configuration:

    <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>
    

    and to socket bindings:

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

    You need to change your topic/connection factory names and user credentials in accordance to your application. Your also have to change your application's messaging configuration to connect to/listen the multicast port in the above example (231.7.7.7:9876 is default).