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