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