How to programatically create a JMS Queue in a Clustered Environment
seniorteaboy May 4, 2016 12:25 PMCurrently we are working on moving our application from a standalone configuration to a domain / clustered configuration.
Our client app is Swing based, and talks to various EJBs in JBoss..
At the point a user logs-in, we currently create a new JMS Queue using the JBoss Native Interface - which works well for us...
however - this only works some times in a clustered environment -- since the JBoss Native Interface code, seems to have to be run on the master node / domain controller,
our code looks like this :
ModelControllerClient client = null;
final ModelNode op = new ModelNode();
final ModelNode address = op.get(ClientConstants.OP_ADDR);
address.add("profile", "full-ha");
address.add("subsystem", "messaging");
address.add("hornetq-server", "default");
// the name of the queue
address.add("jms-queue", queueName);
// the JNDI entries
final ModelNode entries = op.get("entries");
for (final String jndiName : jndiNames) {
entries.add(jndiName);
}
op.get(ClientConstants.OP).set(ClientConstants.ADD);
final ModelNode result = execute(op);
and we can also do the same thing using jboss-cli.sh :
/profile=full-ha/subsystem=messaging/hornetq-server=default/jms-queue=newQueue:add(entries=["jms/queue/newQueue"])
however -- if we try to execute either of these, on a node which is NOT the Domain Controller - we get the following response :
{
"outcome" => "failed",
"failure-description" => "JBAS010849: Operation add for address [
(\"profile\" => \"full-ha\"),
(\"subsystem\" => \"messaging\"),
(\"hornetq-server\" => \"default\"),
(\"jms-queue\" => \"newQueue5\")
] can only be handled by the master Domain Controller; this host is not the master Domain Controller",
"rolled-back" => true
}
The JBoss Native Interface code is executed from a SLSB, which can of course be run on any node in the cluster (which is great from load balancing / HA point of view)..
How can we make this work on any node in the cluster ?
Or is there a way to pin an EJB to a specific node in the cluster ? (e.g. the Domain Controller),
but still have it continue to work if the Domain Controller should go down ? (e.g. have it move to another node in that scenario ?)