I am using 2 Wildfly 11 server instances in standalone mode started with standalone-full-ha.xml.
Now i would like to send JMS Messages between those two by implementing a Sender and a Receiver that uses the same topic like this:
Receiver:
@Named
@MessageDriven(
name="TaskJmsMsgReceiver",
activationConfig={
@javax.ejb.ActivationConfigProperty(propertyName="destinationLookup", propertyValue="topic/Blubb"),
@javax.ejb.ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
@javax.ejb.ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="Auto-acknowledge")
})
public class TaskJmsMsgReceiver implements MessageListener {
@Inject
private TaskWebSocketChannel webSocketChannel;
@Override
public void onMessage(Message rcvMessage) {
TextMessage msg = null;
try {
if (rcvMessage instanceof TextMessage) {
msg = (TextMessage) rcvMessage;
String jmsMessageText = msg.getText();
log.info("Received JMS Message: " + jmsMessageText);
String socketChannelEmpfaenger = jmsMessageText;
webSocketChannel.send(socketChannelEmpfaenger);
}
} catch (JMSException e) {
...
}
}
}
Sender:
@JMSDestinationDefinitions({
@javax.jms.JMSDestinationDefinition(
name = "java:/jms/topic/Blubb",
interfaceName = "javax.jms.Topic",
destinationName = "Blubb")
})
@Stateless
@Dependent
public class TaskJmsMsgSender {
@Resource(lookup = "java:/jms/topic/Blubb")
private Topic topic;
@Inject
private JMSContext context;
public void send(String text) {
log.info("Send JMS Message: " + text);
context.createProducer().send(topic, text);
}
}
Now, obviously I need to configure the Wildfly instances to work together with the same JMS topic.
Can someone pls point me in the right direction how to configure this?
Thanx a lot.