-
1. Re: HornetQ JMS Management API "listMessages" operation not working
jbertram Dec 4, 2014 2:26 PM (in response to ajinkya.bambal)Please provide enough information to actually understand what's happening, e.g.:
- What version of HornetQ are you using?
- Do you see any errors on the client or the server?
- Does "jms.queue.exampleQueue" exist on the server? If so, how is it defined/deployed?
-
2. Re: HornetQ JMS Management API "listMessages" operation not working
ajinkya.bambal Dec 4, 2014 11:45 PM (in response to jbertram)Hi Justin ,
Please find answers inline ,
1) I am using standalone HornetQ 2.3.0.Final version .
2) I dont see any error in server log but in client log following error came ,
Exception occured at listMessages [Ljava.lang.Object; cannot be cast to java.util.Map
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.Map
3)I have defined example queue in hornetq-jms.xml as follows :
<queue name="exampleQueue">
<entry name="/queue/exampleQueue"/>
</queue>
4) I have also added following Management related configuration in hornetq-configuration.xml ,
a) Added ,
<management-address>jms.queue.hornetq.management</management-address>
b) under <security-settings> tag added ,
<security-setting match="jms.queue.hornetq.management">
<permission type="manage" roles="guest" />
</security-setting>
5) I also used JMS management API for "messageCount" (returns integer value) ,"removeMesage" (input : jmsMessageID , returns boolean) ,"removeMessages"(returns integer). But all are working fine except "listMessages"(Which ideally should return Map<String,Object> but it is returning Object) .
Please let me know if you need more inputs from me.
-
3. Re: Re: HornetQ JMS Management API "listMessages" operation not working
jbertram Dec 5, 2014 12:35 PM (in response to ajinkya.bambal)Which ideally should return Map<String,Object> but it is returning Object
These are your fundamental problems:
- You expect the "listMessages" operation to return a Map<String,Object> when it in fact returns a Map<String,Object>[] (i.e. an array of Map<String,Object>). See the JavaDoc.
- You interpret the message from the ClassCastException to indicate that "listMessages" is returning Object when it is in fact return Object[] (i.e. an array of Object). "[Ljava.lang.Object" means an array of java.lang.Object.
Therefore your code should look something like this:
Object[] results = (Object[]) JMSManagementHelper.getResult(reply); for (int i = 0; i < results.length; i++) { Map<String, Object> result = (Map<String, Object>) results[i]; System.out.println("Message: " + result); }
-
4. Re: Re: HornetQ JMS Management API "listMessages" operation not working
ajinkya.bambal Dec 8, 2014 1:10 AM (in response to jbertram)Thanks Justin . It worked for me .