Search code examples
javamessage-queueactivemq-artemisjboss-eap-7

Get process id that is listening to a queue


I am using Apache ActiveMQ Artemis that is embedded within JBoss EAP 7.2.0 server. I have created a queue and and external application (external to the JBoss server) is listening to that queue. In Runtime tab in JBoss Admin Console, I can see that my queue has 1 listener, but after a few days I see that the number of listeners increases to 2 or 3.

Is there any way by which I can get details of the processes that are listening to the queue?


Solution

  • In your specific use case, with only remote consumers on the same host of your EAP server, you can get all connected processes using the following command (note that this doesn't cover the case where you also have internal consumers with the same process id of your server and/or remote consumers on external hosts).

    $ lsof -Pni | grep ">127.0.0.1:8080"
    java      25322 fvaleri  230u  IPv4 0x97a3c5aa109b7ebd      0t0  TCP 127.0.0.1:55058->127.0.0.1:8080 (ESTABLISHED)
    

    Then, each of this connections may have a number of sessions opened, that you can find out with the following command (replace TestQueue with your queue's name).

    $ $EAP_HOME/bin/jboss-cli.sh -c --command="/subsystem=messaging-activemq/server=default/jms-queue=TestQueue:list-consumers-as-json"