Results 1 to 5 of 5

Thread: how to get channel metrics?

  1. #1
    Join Date
    Nov 2012
    Posts
    2

    Default 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. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    646

    Default

    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

  3. #3
    Join Date
    Jun 2007
    Location
    Cork, Ireland
    Posts
    7

    Default

    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 at 06:47 AM.

  4. #4
    Join Date
    Nov 2012
    Posts
    2

    Default

    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

  5. #5
    Join Date
    Jun 2007
    Location
    Cork, Ireland
    Posts
    7

    Default

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •