Core Management Example
ohughes Apr 7, 2011 10:58 AMHi,
I am attempting to write a small utility that will tell me the details about what messages are inside the hornetq server, etc. starting simply with a message count of each queue, and then can be extended later for more detailed logging.
So, I have followed the example within the documentation, but I keep on getting the following error:
Exception in thread "main" HornetQException[errorCode=105 message=Unable to validate user: null for check type CREATE_NON_DURABLE_QUEUE for address hornetq.management.b4c390ce-5a87-445b-88b9-851e17ab47c9] at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:287) at org.hornetq.core.client.impl.ClientSessionImpl.internalCreateQueue(ClientSessionImpl.java:1627) at org.hornetq.core.client.impl.ClientSessionImpl.createTemporaryQueue(ClientSessionImpl.java:306) at org.hornetq.core.client.impl.DelegatingSession.createTemporaryQueue(DelegatingSession.java:306) at org.hornetq.api.core.client.ClientRequestor.<init>(ClientRequestor.java:57) at org.hornetq.api.core.client.ClientRequestor.<init>(ClientRequestor.java:66)
And I have a default user setup in my hornetq-users.xml, which is simply the guest, and here is what I've added to my hornetq-configuration.xml file:
<management-address>hornetq.management</management-address> ... <security-settings> <security-setting match="hornetq.management"> <permission type="manage" roles="guest" /> </security-setting> .... </security-settings>
And simply insided the code its:
private void dumpStats() throws Exception { int count; ClientMessage reply; ClientMessage message; ClientSession clientSession = ...; ClientRequestor requestor = new ClientRequestor(clientSession, "hornetq.management"); //This is the line that blows up for (String queueName : queueNames) { message = clientSession.createMessage(false); ManagementHelper.putAttribute(message, queueName, "messageCount"); reply = requestor.request(message); count = (Integer) ManagementHelper.getResult(reply); System.out.println("# of messages in queue (" + queueName + ") : " + count); } }
Note, that I do not have a jms configuration file, because I don't use any JMS, only the core client.
Any ideas/thoughts are most welcome, and I imagine that it is probably a very simple solution at the end of the day,
Osian