1
2
3
4
5
6
7
8
9
10
11 package org.mule.service.processor;
12
13 import org.mule.api.MuleEvent;
14 import org.mule.api.routing.OutboundRouterCollection;
15 import org.mule.api.service.Service;
16 import org.mule.management.stats.ServiceStatistics;
17 import org.mule.processor.AbstractMessageObserver;
18
19 public class ServiceOutboundStatisticsObserver extends AbstractMessageObserver
20 {
21
22 protected Service service;
23
24 public ServiceOutboundStatisticsObserver(Service service)
25 {
26 this.service = service;
27 }
28
29 @Override
30 public void observe(MuleEvent event)
31 {
32 ServiceStatistics stats = service.getStatistics();
33 if (stats.isEnabled())
34 {
35 if (!(service.getOutboundMessageProcessor() instanceof OutboundRouterCollection)
36 || (service.getOutboundMessageProcessor() instanceof OutboundRouterCollection && ((OutboundRouterCollection) service.getOutboundMessageProcessor()).hasEndpoints()))
37 {
38 if (event.getEndpoint().getExchangePattern().hasResponse())
39 {
40 stats.incSentEventSync();
41 }
42 else
43 {
44 stats.incSentEventASync();
45 }
46 }
47 }
48 }
49 }