I'm running a JBoss Wildfly 8.1.0.Final in domain mode with two nodes ("host-1" and "host-2") and need to send a message from one node to all nodes in the cluster in order to execute a certain action on all of them. The client that sends the message and the message receiver should be in the same EAR.
Since the question has been unanswered and uncommented on so far, I'll break the question down into simpler parts. Please feel free to answer or comment on only a subset so I can investigate further.
Am I correct in assuming that this is a valid use case for a message driven bean? If not, why? In that case, the remainder of the question is probably pointless.
I created a
javax.jms.Topic
in thedomain.xml
of the JBoss cluster's domain-controller, "host-1". Correct in principle?The client that intends to send the message, looks up the
Topic
andConnectionFactory
via JNDI (as opposed to, e.g., having it injected). Is that the right approach?The MDB which is to receive the message is configured to listen to that
Topic
via an@ActivationConfigProperty
. Correct?
The above setup works locally, i.e. the message is received only by the node that sends it. It is not received by other nodes. The client code that sends the message is triggered from a WAR, and the message is received by a MDB in an EJB module in the same EAR.
I am unsure whether we need a RemoteConnectionFactory
or whether we need to use a different way to look up the topic (currently injected into MDB and looked up by the client as java:/jms/rmcTopic
), since it is actually defined on a remote host.
This is my topic in domain.xml. I know the <clustered>
tag is deprecated, but I could not find recent documentation for how this is done with 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>
The MDB is packaged as an EJB module in an EAR, and the MDB annotations are:
@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
Log output indicates that useSharedSubscriptionInClusteredContainer
and connectionFactoryJndiName
are not supported, but again I'm keeping them as a reference to failed attempts of mine :-)
The code that sends the message is inside a WAR in the same 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);
Any help is greatly appreciated.