Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the contents of an AMQ topic be viewed somehow?

Tags:

java

jms

activemq

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,

like image 443
Simeon Avatar asked Jun 27 '12 12:06

Simeon


People also ask

What is AMQ topic?

What Is an ActiveMQ Topic? ActiveMQ topic is a pipeline of messages where a message comes in and goes to every subscriber.

How do you consume a message from ActiveMQ queue?

createConsumer("MyQueue"); listener = new MyListener (); consumer. setMessageListener(listener); connection. start(); // At this point, messages should arrive from the queue to your listener.


2 Answers

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.

like image 158
Jakub Korab Avatar answered Oct 30 '22 08:10

Jakub Korab


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.

like image 30
sync Avatar answered Oct 30 '22 07:10

sync