使用JBoss进行Wildfly群集

时间:2019-05-07 16:35:12

标签: wildfly jgroups activemq-artemis

我正在尝试设置Wildfly 11集群,但无法使其正常运行。基本上,我有2个Wildfly实例,其中一个实例的port-offset = 2运行在本地计算机上。这是发布者和MDB:

@JMSDestinationDefinitions(value = { @JMSDestinationDefinition(name = "java:/topic/CLUSTEREVENTTOPIC", interfaceName = "javax.jms.Topic", destinationName = "ClusterEventTopic") })
@Stateless
public class ClusterEventPublisher implements Serializable {

MDB

@MessageDriven(name = "ClusterEventMonitor", activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/CLUSTEREVENTTOPIC"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class ClusterEventMonitor implements MessageListener {

请注意,我能够看到在Wildfly上创建的该主题,但是当我发布关于该主题的消息时。仅由发送消息的节点读取。

例如: node1发送一个eventDto作为消息,node1将接收该消息,但node2将不接收。

请注意,我正在使用standalone-full-ha.xml配置。我刚刚在ActiveMQ模块中添加了以下行:

<cluster password="${jboss.messaging.cluster.password:opencell}"/>

可以从以下位置下载完整配置,请注意,第二个实例具有完全相同的配置,唯一的区别是端口偏移值:

https://www.dropbox.com/s/0ttyb05dx7cps21/standalone-full-ha-test.xml

我处于调试模式,请确保消息未到达node2。有想法吗?

1 个答案:

答案 0 :(得分:0)

我现在能够通过node2中的JMS接收从node1发送的消息。但是,我真的什么也没做。我比较了我的配置文件,它们与我无法使用的第一组节点几乎相同。我所做的只是下载了一个新的Wildfly 11压缩文件,进行了必要的数据库配置,然后它起作用了。对于那些询问的人,这是我的standalone-full-ha.xml配置的一部分:

<subsystem xmlns="urn:jboss:domain:jgroups:5.0">
    <channels default="ee">
        <channel name="ee" stack="udp" cluster="ejb"/>
    </channels>
    <stacks>
        <stack name="udp">
            <transport type="UDP" socket-binding="jgroups-udp"/>
            <protocol type="PING"/>
            <protocol type="MERGE3"/>
            <protocol type="FD_SOCK"/>
            <protocol type="FD_ALL"/>
            <protocol type="VERIFY_SUSPECT"/>
            <protocol type="pbcast.NAKACK2"/>
            <protocol type="UNICAST3"/>
            <protocol type="pbcast.STABLE"/>
            <protocol type="pbcast.GMS"/>
            <protocol type="UFC"/>
            <protocol type="MFC"/>
            <protocol type="FRAG2"/>
        </stack>
        <stack name="tcp">
            <transport type="TCP" socket-binding="jgroups-tcp"/>
            <socket-protocol type="MPING" socket-binding="jgroups-mping"/>
            <protocol type="MERGE3"/>
            <protocol type="FD_SOCK"/>
            <protocol type="FD_ALL"/>
            <protocol type="VERIFY_SUSPECT"/>
            <protocol type="pbcast.NAKACK2"/>
            <protocol type="UNICAST3"/>
            <protocol type="pbcast.STABLE"/>
            <protocol type="pbcast.GMS"/>
            <protocol type="MFC"/>
            <protocol type="FRAG2"/>
        </stack>
    </stacks>
</subsystem>

<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
    <server name="default">
        <cluster password="${jboss.messaging.cluster.password:secret}"/>
        <security-setting name="#">
            <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
        </security-setting>
        <address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10" redistribution-delay="1000"/>
        <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
        <http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
            <param name="batch-delay" value="50"/>
        </http-connector>
        <in-vm-connector name="in-vm" server-id="0">
            <param name="buffer-pooling" value="false"/>
        </in-vm-connector>
        <http-acceptor name="http-acceptor" http-listener="default"/>
        <http-acceptor name="http-acceptor-throughput" http-listener="default">
            <param name="batch-delay" value="50"/>
            <param name="direct-deliver" value="false"/>
        </http-acceptor>
        <in-vm-acceptor name="in-vm" server-id="0">
            <param name="buffer-pooling" value="false"/>
        </in-vm-acceptor>
        <broadcast-group name="bg-group1" jgroups-channel="activemq-cluster" connectors="http-connector"/>
        <discovery-group name="dg-group1" jgroups-channel="activemq-cluster"/>
        <cluster-connection name="my-cluster" address="jms" connector-name="http-connector" discovery-group="dg-group1"/>
        <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
        <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
        <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
        <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector" ha="true" block-on-acknowledge="true" reconnect-attempts="-1"/>
        <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
    </server>
</subsystem>

对于infinispan缓存:

<cache-container name="projectx">
    <transport lock-timeout="60000"/>
    <replicated-cache name="projectx-cache" mode="SYNC">
        <transaction mode="NON_XA"/>
        <eviction strategy="LRU" max-entries="100000"/>
    </replicated-cache>