I have three machines located in different networks:
- as-master
- as-node-1
- as-node-2
In as-master I have WildFly as domain host-master and the two nodes have WildFly as domain host-slave each starting an instance in the full-ha server group. From the as-master web console I can see the two nodes in the full-ha profile runtime and if I deploy a WAR it gets correctly started on both nodes.
Now, what I'm trying to achieve is messaging between the two instances of the WAR, i.e. sending a message from a producer instance in as-node-1, consumers in all the nodes should receive the message.
This is what I tried: added a topic to WildFly domain.xml
:
<jms-topic name="MyTopic" entries="java:/jms/my-topic"/>
Create a JAX-RS endpoint to trigger a producer bound to the topic:
@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!");
}
}
Create a MDB listening to the topic:
@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);
}
}
}
But when I curl as-node-1/jms
I see the log only in as-node-1, and when I curl as-node-2/jms
I see the log only in as-node-2.
Shouldn't the message be delivered on all the nodes where the WAR is deployed? What am I missing?