Hi,
I am trying to create queues on two different addresses using the same
ActiveMQServerControl connection. Both addresses get created correctly and the
queue on the first address gets created correctly but for some reason when I
try to create the second queue on the second address it tries to put the queue
on the first address. Is this normal behaviour, am I missing something here, do
I need to have one ActiveMQServerControl connection for each address? That
seems strange to me.
Here is the code I am using to set everything up:
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.io.IOException;
import static java.lang.Boolean.FALSE;
public class TestQueueBroker {
public static void main (String args[]) throws Exception {
TestQueueBroker tqb = new TestQueueBroker();
tqb.setupActiveMQServerControlConnection("192.168.0.240");
tqb.init();
}
ActiveMQServerControl serverControl;
MBeanServerConnection connection;
public TestQueueBroker() throws Exception {
}
void init() throws Exception {
String topology_address_tp001 = "primary_topology_pipeline_TP_001";
String topology_address_tp002 = "primary_topology_pipeline_TP_002";
this.serverControl.createAddress(topology_address_tp001,"ANYCAST");
this.serverControl.createAddress(topology_address_tp002,"ANYCAST");
String new_queue_name = "_to_be_forwarded";
String queueFilter = "";
Boolean is_durable = FALSE;
String queueType = "ANYCAST";
this.serverControl.createQueue(topology_address_tp001, new_queue_name,
queueFilter, is_durable ,queueType);
this.serverControl.createQueue(topology_address_tp002, new_queue_name,
queueFilter, is_durable ,queueType);
}
void setupActiveMQServerControlConnection(String broker_ip) throws
IOException, MalformedObjectNameException {
//Setup the mBean server that we will use for all operations
JMXConnector connector = JMXConnectorFactory.connect(new
JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + broker_ip + ":3000/jmxrmi"));
connector.connect();
this.connection = connector.getMBeanServerConnection();
String beanName = "org.apache.activemq.artemis:broker=" +
"\"merlin01\"";
ObjectName server_mbeanName = new ObjectName(beanName);
this.serverControl =
MBeanServerInvocationHandler.newProxyInstance(connection, server_mbeanName,
ActiveMQServerControl.class, true);
}
}