I run JBoss Wildfly 8.1.0.Final in domain mode with two nodes ("host-1" and "host-2"), and you need to send a message from one node to all nodes in the cluster in order to perform a specific action for all of them. The client that sends the message and the message receiver must be in the same EAR.
Since the question is still unanswered and uncommented, I will break the question down into simpler parts. Please feel free to reply or comment on only a subset so that I can continue the study.
Do I think this is a valid use case for a bean driven message? If not, why? In this case, the rest of the question is probably meaningless.
I created javax.jms.Topicin the domain.xmlJBoss cluster domain controller, "host-1". Is it correct in principle?
A client who intends to send a message, viewing Topicand ConnectionFactoryvia JNDI (as opposed to, for example, entering it). Is this the right approach?
The MDB that should receive the message is configured to listen to this Topicthrough @ActivationConfigProperty. Correctly?
The above setting works locally, that is, the message is only accepted by the sender node. It is not accepted by other nodes. The client code that sends the message is launched from the WAR, and the message is received by the MDB in the EJB module in the same EAR.
, RemoteConnectionFactory, ( MDB java:/jms/rmcTopic), .
domain.xml. , <clustered> , , Wildfly 8.1.
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<clustered>true</clustered>
<cluster-user>hornetqcluster</cluster-user>
<cluster-password>hornetqcluster</cluster-password>
<jms-connection-factories>
<connection-factory name="RemoteConnectionFactory">
<connectors>
<connector-ref connector-name="http-connector"/>
</connectors>
<entries>
<entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
</entries>
</connection-factory>
</jms-connection-factories>
<jms-destinations>
<jms-topic name="rmcTopic">
<entry name="java:/jms/rmcTopic"/>
</jms-topic>
</jms-destinations>
</hornetq-server>
</subsystem>
MDB EJB- EAR, MDB:
@MessageDriven(name = "ConfigurationMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/jms/rmcTopic"),
@ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "RemoteConnectionFactory"),
@ActivationConfigProperty(propertyName = "addressList", propertyValue = "host-1"),
@ActivationConfigProperty(propertyName = "useSharedSubscriptionInClusteredContainer", propertyValue = "false") })
public class ConfigurationMDB implements MessageListener
, useSharedSubscriptionInClusteredContainer connectionFactoryJndiName , : -)
, , WAR EAR:
Context ic = new InitialContext();
ConnectionFactory cf = (ConnectionFactory) ic.lookup("java:jboss/exported/jms/RemoteConnectionFactory");
Topic topic = (Topic) ic.lookup("java:/jms/rmcTopic");
Connection connection = cf.createConnection("hornetqcluster", "hornetqcluster");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer publisher = session.createProducer(topic);
connection.start();
TextMessage message = session.createTextMessage("Test");
publisher.send(message);
.