问题
I'm trying to view the contents of a topic using activemq-admin.
This is what I'm trying:
./activemq-admin browse --amqurl tcp://localhost:61616 my.topic
This is what I get as output:
Java Runtime: Sun Microsystems Inc. 1.6.0_24 /usr/lib/jvm/java-6-sun-1.6.0.24/jre
Heap sizes: current=62848k free=62190k max=932096k
JVM args: -Dactivemq.classpath=/home/pc/dev/apache-activemq-5.3.1/conf; -Dactivemq.home=/home/pc/dev/apache-activemq-5.3.1 -Dactivemq.base=/home/pc/dev/apache-activemq-5.3.1
ACTIVEMQ_HOME: /home/pc/dev/apache-activemq-5.3.1
ACTIVEMQ_BASE: /home/pc/dev/apache-activemq-5.3.1
Which is not what I want. I want to see the messages in the queue in raw form somehow. Is that possible ?
Thanks,
回答1:
You cannot browse the contents of topics due to the nature of what a topic is. Messages are sent in, and if there are any subscribers, each receives a message at that point in time. Messages are generally not retained (with some exceptions that aren't relevant here).
However, sometimes for debugging purposes it's useful to see messages that were sent to a topic. The easiest way to do so is to set up a virtual destination, that copies each message sent to the topic into a queue.
<destinationInterceptors>
<virtualDestinationInterceptor>
<virtualDestinations>
<compositeTopic name="events" forwardOnly="false">
<forwardTo>
<queue physicalName="events.thatHaveHappened" />
</forwardTo>
</compositeTopic>
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>
You can then browse the queue via JMX or the web console.
回答2:
You can view the content of the messages in the Queue using the web console
回答3:
This third-party tool lets you subscribe to topics and inspect the messages to a topic:
http://sourceforge.net/projects/activemqbrowser/
Connect to the server, then subscribe to the topic you want. It worked OK for me to look at the message details and payloads.
来源:https://stackoverflow.com/questions/11226485/can-the-contents-of-an-amq-topic-be-viewed-somehow