使用 JBoss 的 Wildfly 聚类

Wildfly Clustering using JBoss

我正在尝试设置 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

我处于调试模式并确保消息没有到达节点 2。有什么想法吗?

我现在可以通过 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>

至于无限缓存:

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

和 ActiveMQ

<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
    <server name="default">
        <cluster password="${jboss.messaging.cluster.password:secret}"/>

确保将服务器绑定到 IP 地址或 0.0.0.0 以进行测试。