Managing & Monitoring
In the What is Consumer Dispatcher and Why part, we go through the functionality list that Consumer Dispatcher provides. Now we will introduce how to use those functionality and how to monitor the system.
We have 2 ways to manage and monitor the system, both of them are based on JMX.
- use jconsole
- web based client (in case you dont have jconsole, but you have browser)
the ports for jconsole and webbased interface are configed in job.xml
<monitor rHost="localhost" rPort="9999" httpHost="localhost" httpPort="8888"/>
It's likely to link JMX with jconsole together. Many people will use jconsole to monitor java system, so do we!
If you have Java environment installed, you have jconsole.
You can goto your $JAVA_HOME/bin to start jconsole up.
cd $JAVA_HOME
./jconsole
or you can directly run jconsole
from your terminal if your PATH already include it.
When you start up consumer Dispatcher, , you will find something like
jmx.ConsumerDispatcherMonitor(Line:43) [main] - JMX enabled on:service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi
in the log file, if you enable INFO logger level.
this is the address you need to provide into jconsole.
fill in service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi
(change localhost to your target ip) and click 'connect'
after connected, you see tabs and information provided by default. Please click on 'MBeans' tab and navigate to ‘your domain’ -> 'queue name' -> 'rabbitmq server' -> 'vhost' in the left box.
you will have option to see 'attributes' and do some 'operation' on the suposed queue.
click on the 'attributes' node, it shows you
- how many working job executor is there for that queue (How it works)
- how many job has been consumed for this queue
click on the 'operations' node, you can perform different functionalities that Consumer Dispatcher provides (functionality list)
-
addJobExecutor:
(function explanation)
parameter p1: the number of job executors you would like to add. say, if there is running 1 job executor already, then inputting 3 and clicking 'addJobExecutor' button results in 4 executors running for this queue. -
removeJobExecutors:
(function explanation)
parameter p1: the number of job executors you would like to remove. say, if there is running 30 job executor already, then inputting 10 and clicking 'removeJobExecutors' button results in 20 executors running for this queue. -
stopAllExecutors:
stop all consumers for that queue. after stopping all, if you need to run consumer code again, you can use 'addJobExecutor' button. -
purgeQueue:
(function explanation and use case) -
logErrorJobToFile:
(function explanation and use case)
web based client provides exactly the same stuff as jconsole does.
If you have mx4j-tool.jar in your classpath (by default, it's packaged into the jar, so enabled by defalut)
When you start up consumer Dispatcher, , you will find something like
INFO jmx.ConsumerDispatcherMonitor(Line:71) [main] - mx4j successfuly loaded at localhost:8888
in the log file, if you enable INFO logger level.
visit http://localhost:8888
with your browser, on which you could do the same operations as described above.