-
1. Re: destroyTopic using MBeanServer, Error:cannot delete topic , it has consumers
jbertram Apr 11, 2014 1:24 PM (in response to alexpass)The destroyTopic method is overloaded. Try using the one that takes a String and a boolean. The boolean indicates whether or not the consumers should be removed before the topic is destroyed.
-
2. Re: destroyTopic using MBeanServer, Error:cannot delete topic , it has consumers
alexpass Apr 30, 2014 9:44 AM (in response to jbertram)Unfortunately, it doesn't work. I tried to do it so, as it is shown in JavaDocs :
The countMatches operation can be invoked as follows:
String[] myPatterns = ...;
int count = (Integer) mbeanServerConnection.invoke( objectName, "countMatches", new Object[] {myPatterns, true}, new String[] {String[].class.getName(), boolean.class.getName()});
Here is my code with some variants:
....
mBeanServer = (MBeanServer) javax.management.MBeanServerFactory
.findMBeanServer(null).iterator().next();
try {
on = ObjectNameBuilder.DEFAULT.getJMSServerObjectName();
mBeanServer.invoke(on, "destroyTopic" , new Object[] { topicName, true }, new String[] {"java.lang.String" });
v.2//mBeanServer.invoke(on, "destroyTopic" , new Object[] { topicName, true }, new String[] {"java.lang.String" , boolean.class.getName()}); ERROR: javax.management.ReflectionException: Signature mismatch for operation destroyTopic: (java.lang.String, java.lang.Boolean) should be (java.lang.String)
v.3//mBeanServer.invoke(on, "destroyTopic" , new Object[] { topicName, true }, new String[] {"java.lang.String" ,"java.lang.Boolean"}); ERROR: smth, like too many parameters
} catch (Exception e) {
e.printStackTrace();
}
...
No one of variant works. How can I invoke destroyTopic, which takes these two parameter : String and boolean? Thx!
BTW: Question 2: I actually want to implement a client on Android using Hornetq, but it is not possible, as Android has no javax.* packages. I've read a lot of about it and found a solution to repackage android's packages. but it is not a good idea. Do you know maybe, wich other tools is it better to use? Maybe ActiveMQ in JBoos, as Android can send messages to Queue in ActiveMQ? Would be nice, if you gave me some tipp.
-
3. Re: destroyTopic using MBeanServer, Error:cannot delete topic , it has consumers
jbertram May 2, 2014 9:36 AM (in response to alexpass)1 of 1 people found this helpfulWhat version of HornetQ are you using? You'll need to be on at least 2.4.1.Final to get access to org.hornetq.api.jms.management.JMSServerControl.destroyTopic(java.lang.String, boolean) as it wasn't in earlier versions.
Also, if you want to use HornetQ from a mobile client try looking at either our REST or STOMP stuff in the documentation.
-
4. Re: destroyTopic using MBeanServer, Error:cannot delete topic , it has consumers
alexpass May 7, 2014 11:11 AM (in response to jbertram)Thanks for the helpful answer, I updated the hornetq to version 2.4.1 and can see now the function.
Regarding using HornetQ from a mobile client your tip brought me a bit forward.
According to this page I installed the enviroment and Bootstrapped the HornetQ Along with REST including configuration so far.
Before I had a MessagDriveBean in a ejb-module, where I receive a message and processed it:
@MessageDriven(name = "MessageMDBSample", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/test"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class QueueListenerMDB implements MessageListener {
@Resource(mappedName = "java:/JmsXA")
ConnectionFactory connectionFactory;
private Session session;
Connection conn;
MBeanServer mBeanServer;
ObjectName on;
Queue replyDest;
public void onMessage(Message message) {
try {
// message processing, as involve creating new Queue at runtime : mBeanServer.invoke(on, "createTopic", new Object[] { TopicName },
// new String[] { "java.lang.String" }); and so on
} catch (JMSException e) {
e.printStackTrace();
}
}
}
I set up the REST in web-module in order to get a .war file and here it is not possible to have MDB.
Is it possible to process the message using REST on the same way , as it is in ejb with MDB? Do the messages come on anyplace on the server, so that it would be possible to read it and for example create a new queue or topic at runtime, send responce to the client and other operations?
-
5. Re: destroyTopic using MBeanServer, Error:cannot delete topic , it has consumers
jbertram May 12, 2014 12:13 PM (in response to alexpass)Take a look at the documentation: Chapter 43. REST Interface.
-
6. Re: destroyTopic using MBeanServer, Error:cannot delete topic , it has consumers
alexpass May 19, 2014 3:57 AM (in response to jbertram)Thanks for the tip. I tried it before, the difficulty is with REST, that a Listener on Client is not provided.It should be implemented with a repeated pull function. In my case, i.e. a chat, it is'n efficiently.
I will look for a solution.
-
7. Re: destroyTopic using MBeanServer, Error:cannot delete topic , it has consumers
jbertram May 19, 2014 10:16 AM (in response to alexpass)Use a push consumer?