WildFly 10 Domain Cluster Exchange Service

I have three machines located on different networks:

  • as masters
  • like- node 1
  • like- node -2

In as-master, I have WildFly as the host of the domain host, and two nodes have WildFly as the host-slave of the domain, each of which runs an instance in the full-ha server group. From the as-master web console, I see two nodes in full-screen runtime, and if I break the WAR, it will run correctly on both nodes.

Now, what I'm trying to achieve is the exchange of messages between two WAR instances, that is, sending a message from a manufacturer instance to as-node -1, consumers in all nodes should receive a message.

Here is what I tried: added a theme to WildFly domain.xml:

<jms-topic name="MyTopic" entries="java:/jms/my-topic"/>

Create a JAX-RS endpoint to invoke the manufacturer associated with the theme:

@Path("jms")
@RequestScoped
public class MessageEndpoint {

    @Inject
    JMSContext context;

    @Resource(mappedName = "java:/jms/my-topic")
    Topic myTopic;

    @GET
    public void sendMessage() {
         this.context.createProducer().send(this.myTopic, "Hello!");
    }

}

MDB, :

@MessageDriven(activationConfig = {
    @ActivationConfigProperty(
        propertyName = "destination",
        propertyValue = "java:/jms/my-topic"
    ),
    @ActivationConfigProperty(
        propertyName = "destinationType",
        propertyValue = "javax.jms.Topic")
    )
)
public class MyMessageListener implements MessageListener {

    private final static Logger LOGGER = /* ... */

    public void onMessage(Message message) {
        try {
            String body = message.getBody(String.class)
            LOGGER.info("Received message: " + body);
        } catch (JMSException e) {
            throw new RuntimeException(e);
        }
    }

}

curl as-node-1/jms, as- node -1, curl as-node-2/jms, as- node -2.

, WAR? ?

+1
1

- .

, , .

ActiveMQ Artemis ActiveMQ ( ):

<discovery-group name="dg-group1" jgroups-channel="activemq-cluster"/>
<cluster-connection name="my-cluster" discovery-group="dg-group1" connector-name="http-connector" address="jms"/>

- , JNDI jms "jms", address="jms" ( : "java:/jms/my-topic" )

, , :
<cluster password="yourPassword" user="activemqUser"/>
( activemqUser , , addUser.sh script).

ActiveMQ . Core Bridge . ActiveMQ:

.. - node

, server.log: AMQ221027: Bridge ClusterConnectionBridge@63549ead [name=sf.my-cluster ...] is connected.

Btw, , ActiveMQ , .

P.s. , .

+2

All Articles