Announcement Announcement Module
Collapse
No announcement yet.
how to get channel metrics? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to get channel metrics?

    Hi Guys,

    I need to check channel's statistics (for example timeSinceLastSend attribute)
    I've added jmx to my project and now i can view channel's metrics via Java VisualVM
    But could you tell me how can i get channel's timeSinceLastSend value programmatically?

    Thanks,
    Alex

  • #2
    Hello

    As I understand you're using in your application this one IntegrationMBeanExporter.
    This component collects all Metrics for all SI-components. But it doesn't provide info about 'timeSinceLastSend'.
    But you can use in you app JMX-endpoints as well as you can see them in the VisualVM:
    http://static.springsource.org/sprin...apter.html#jmx
    https://github.com/SpringSource/spri...ster/basic/jmx

    HTH

    Take care,
    Artem

    Comment


    • #3
      Hello Alex,

      by enabling JMX in a Spring Integration app [1] you expose some components as MBeans, therefore you can access any of those by using the standard JMX API. However, Spring provides more convenient way to access MBeans using Spring JMX support[2]. For example, given the "monitoring" sample [3] you can expose the desired channel metric as follows:

      Step 1 - Add "twitterChannel" MBean proxy
      Code:
      <bean id="twitterChannelMetrics" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
        <property name="objectName" value="spring.application:type=MessageChannel,name=twitterChannel"/>
        <property name="proxyInterface" value="org.springframework.integration.monitor.MessageChannelMetrics"/>
      </bean>
      Step 2 - Dep. inject the "twitterChannelMetrics" bean and call the desired method
      Code:
      ...
      @Autowired
      private MessageChannelMetrics twitterChannelMetrics;
      ...
      double tsls = twitterChannelMetrics.getTimeSinceLastSend();
      ...
      Also, if you are interested check out Gary Russell's awesome webinar on monit. and manag. SI apps [4].

      Cheers,
      Michal

      [1] http://static.springsource.org/sprin...mbean-exporter
      [2] http://static.springsource.org/sprin...html#jmx-proxy
      [3] https://github.com/SpringSource/spri...ate/monitoring
      [4] http://www.youtube.com/watch?v=fkZcF47NRu0
      Last edited by michal.jemala; Nov 28th, 2012, 07:47 AM.

      Comment


      • #4
        Thanks All for answers!

        But I have an error "org.springframework.jmx.access.InvalidInvocationE xception" while accessing to @Autowired private MessageChannelMetrics attribute (getTimeSinceLastSend()).

        I'm trying to get statistics for <int-jms:channel ... auto-startup="true"/>

        Thanks,
        Alex

        Comment


        • #5
          Hi Alex,

          its hard to say what's the cause of your problem without seeing the actual code. I tried to expose the metrics mbean for jms channel and it worked as expected. I have pushed the modified monitoring sample to my github repo [1]. Go through the code, it may give you some hints.

          Cheers,
          M.

          [1] https://github.com/michaljemala/play...ter/monitoring

          Comment

          Working...
          X