JMSQueueControl removeAllMessages() not working for me
neraj9 Jan 12, 2015 8:38 AMI am facing problems with hornetq jmx in my integration tests and need your guidance on the same.
I am using HornetQ version 2.2.13.Final in the project. Its a Spring based application. HornetQ is run in embedded fashion and started using JMSServerManager.start()
The queueControl beans are created in the code as below:
Following is the code taken from a class annotated with spring @Configuration
@Bean(name="requestQueueControl")
public JMSQueueControl requestQueueControl() throws Exception {
return queueControl(requestQueueDestination);
}
private JMSQueueControl queueControl(String queueName) throws Exception {
ObjectName queueObjectName = new ObjectName("org.hornetq:module=JMS,type=Queue,name=\""+ queueName + "\"");
MBeanServerConnection mBeanServerConnection = connector().getMBeanServerConnection();
JMSQueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mBeanServerConnection,queueObjectName,JMSQueueControl.class,false);
return queueControl;
}
I am running jmx server using:
public void runJMXServer() throws UnknownHostException,
MalformedURLException, IOException {
LocateRegistry.createRegistry(3001);
System.out.println("Get the platform's MBean server");
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
HashMap<String,Object> env = new HashMap<String,Object>();
System.out.println("Create an RMI connector server");
final String hostname = InetAddress.getLocalHost().getHostName();
JMXServiceURL url =
new JMXServiceURL("service:jmx:rmi://"+hostname+
":"+3001+"/jndi/rmi://"+hostname+":"+3001+"/jmxrmi");
// Now create the server for the JMXServiceURL
JMXConnectorServer cs =
JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
// Start the RMI connector server.
System.out.println("Start the RMI connector server on port "+3001);
cs.start();
}
In my integration test I am doing the following
@Autowired
@Qualifier("requestQueueControl")
private JMSQueueControl requestQueueControl;
However when I invoke
requestQueueUtil.removeAllMessages();
it doesn't result in removal of all messages from the queue
I do not get any exceptions though
also,
requestQueueUtil.pause() is also not working
Other methods like getMessageCount(), getMessagesAdded() are working as expected.
How can I get requestQueueUtil.removeAllMessages(); to work
Thanks!
: