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 | 0 | { |
26 | 0 | this.service = service; |
27 | 0 | } |
28 | |
|
29 | |
@Override |
30 | |
public void observe(MuleEvent event) |
31 | |
{ |
32 | 0 | ServiceStatistics stats = service.getStatistics(); |
33 | 0 | if (stats.isEnabled()) |
34 | |
{ |
35 | 0 | if (!(service.getOutboundMessageProcessor() instanceof OutboundRouterCollection) |
36 | |
|| (service.getOutboundMessageProcessor() instanceof OutboundRouterCollection && ((OutboundRouterCollection) service.getOutboundMessageProcessor()).hasEndpoints())) |
37 | |
{ |
38 | 0 | if (event.getEndpoint().getExchangePattern().hasResponse()) |
39 | |
{ |
40 | 0 | stats.incSentEventSync(); |
41 | |
} |
42 | |
else |
43 | |
{ |
44 | 0 | stats.incSentEventASync(); |
45 | |
} |
46 | |
} |
47 | |
} |
48 | 0 | } |
49 | |
} |