Files
spring-integration-samples/basic/jmx
Artem Bilan 5f524dc534 Upgrade to SI-5.0 & SIK-3.0, Reactor 3.0
* Fix compatibility after Java DSL migration to the SI Core
* Also upgrade all the JMS sample to the JMS 2.0
* Fix default `connectionFactory` bean reference to the current `jmsConnectionFactory`
* Remove unsupported JPA-1.0 Spec via `OpenJpaAutoConfiguration`, since the minimum now is JPA-2.0
* Remove non-lambda sample since minimum now is Java 8
* Rename `PromiseTest` to `MonoTest` and fix it to Reactor 3.0
* Fix `stomp-server.xml` to use proper Reactor 3.0 `eactor.util.function.Tuples` for SpEL
* Regenerate POMs
2016-11-18 14:11:32 -05:00
..

JMX Sample

This example demonstrates the following aspects of the JMX support available with Spring Integration:

  1. JMX Attribute Polling Channel
  2. JMX Operation Invoking Channel Adapter

StopWatch is a Managed Bean. It is bootstraped and deployed using annotation support (@Component, @ManagedResource) and component scanning functionality provided by Spring JMX. Internally StopWatch simply runs a task that increments the value of its seconds attribute by 1 every second.

The JMX Attribute Polling Channel Adapter simply polls a managed attribute seconds of the StopWatch MBean identified by the name:

org.springframework.integration.samples.jmx:type=StopWatch,name=stopWatch

It sends its value to a seconds channel. The interesting part is that the seconds channel is a publish-subscribe-channel and has two subscribers:

  • Stdout Channel Adapter which prints the value of the polled attribute to the console
  • Filter which essentially waits till the payload value is 10

Once the payload value is 10, the filter sends the Message to a reset channel, which is represented as JMX Operation Invoking Channel Adapter. That adapter simply invokes the reset operation on the same StopWatch MBean resetting the seconds attribute value back to 1 and the process repeats.

To run the JMX Adapter sample simply execute JmxAdapterDemoTest. You will see output similar to this, which will loop for ~20 seconds:

1
2
3
4
5
6
7
8
9
10
1
2
3
. . .