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.MuleException;
15 import org.mule.api.processor.MessageProcessor;
16 import org.mule.api.routing.OutboundRouterCollection;
17 import org.mule.api.service.Service;
18 import org.mule.management.stats.ServiceStatistics;
19
20 public class ServiceOutboundStatisticsMessageProcessor implements MessageProcessor
21 {
22
23 protected Service service;
24
25 public ServiceOutboundStatisticsMessageProcessor(Service service)
26 {
27 this.service = service;
28 }
29
30 public MuleEvent process(MuleEvent event) throws MuleException
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.getExchangePattern().hasResponse())
39 {
40 stats.incSentEventSync();
41 }
42 else
43 {
44 stats.incSentEventASync();
45 }
46 }
47 }
48
49 return event;
50 }
51 }