JMS Mbean Configuration in Spring Integration
Join the DZone community and get the full member experience.
Join For Free- download activemq and unzip it
- run activemq.bat under <activemq-home>/bin folder
- go to browser and type http://localhost:8161/admin/queues.jsp , create a new queue “myqueue”
- get the latest code from github
- build the war file using “mvn clean package”
- deploy the war file in spring tomcat container
- “send to” message to myqueue in admin console of activemq in the browser
- you notice the message gets consumed
- open jconsole.exe under jdk bin directory
- login in to remote process “localhost:6969″, uid: admin, password: “springsource”
- go to mbean tab and expand spring.application/jmscontainer/testqueuecontainer/operation, click on stop operation
- again “send to” message to myqueue in admin console of activemq in the browser, if you notice, the message is not consumed
- go to mbean tab and expand spring.application/jmscontainer/testqueuecontainer/operation, click on start operation
-
again “send to” message to myqueue in admin console of activemq in the browser, if you notice, the message got consumed
details: spring integration jms mbean configuration
in a typical enterprise it production environment, you need to control the message processing by the queue subscribers. a typical scenario would be, if there is a an issue with the subscriber and we want to pause the subscriber to troubleshoot it, we need a mechanism for this as below.
expose lifecycle interface of defaultmessagelistenercontainer
<bean id="queue.exporter" class="org.springframework.jmx.export.mbeanexporter"> <property name="beans"> <map> <entry key="spring.application:type=jmscontainer,name=testqueuecontainer" value-ref="queuecontainer" /> </map> </property> <property name="assembler"> <bean class="org.springframework.jmx.export.assembler.interfacebasedmbeaninfoassembler"> <property name="managedinterfaces"> <value>org.springframework.context.lifecycle</value> </property> </bean> </property> </bean>
interfacebasedmbeaninfoassembler class expose an interface of a particular class as a mbean, in the above example it exposes lifecycle
managing jms subscriber in jconsole
- managing jms subscriber using jconsole
when you click on start operation, and click on start button, it will start the subscriber to listen to the message and when you click on stop, it will pause the subscriber.
conclusion
mbean is a powerful way to expose some of the capabilities of spring integration’s various channel adapter, so that you can control them from various tools which are mbean aware, like jconsole, hyperic . we can also expose, log4j mbean so that we can change the log level in the production system. more on this in my subsequent blog.
Published at DZone with permission of Krishna Prasad, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments