1
2
3
4
5
6
7
8
9
10
11 package org.mule.service;
12
13 import org.mule.api.MuleException;
14 import org.mule.api.processor.MessageProcessor;
15 import org.mule.api.routing.Aggregator;
16 import org.mule.management.stats.RouterStatistics;
17 import org.mule.processor.builder.InterceptingChainMessageProcessorBuilder;
18 import org.mule.routing.AbstractAggregator;
19 import org.mule.source.StartableCompositeMessageSource;
20
21
22
23
24
25 public class ServiceAsyncReplyCompositeMessageSource extends ServiceCompositeMessageSource
26 {
27 protected Long timeout;
28 protected boolean failOnTimeout = true;
29
30 public ServiceAsyncReplyCompositeMessageSource()
31 {
32 statistics = new RouterStatistics(RouterStatistics.TYPE_RESPONSE);
33 }
34
35 protected void createMessageProcessorChain() throws MuleException
36 {
37 InterceptingChainMessageProcessorBuilder builder = new InterceptingChainMessageProcessorBuilder(flowConstruct);
38 builder.chain(processors);
39 builder.chain(listener);
40 listener = builder.build();
41 }
42
43 public Long getTimeout()
44 {
45 return timeout;
46 }
47
48 public void setTimeout(Long timeout)
49 {
50 this.timeout = timeout;
51 }
52
53 public boolean isFailOnTimeout()
54 {
55 return failOnTimeout;
56 }
57
58 public void setFailOnTimeout(boolean failOnTimeout)
59 {
60 this.failOnTimeout = failOnTimeout;
61 }
62
63 public void expireAggregation(String groupId)
64 {
65 for (MessageProcessor processor : processors)
66 {
67 if (processor instanceof Aggregator)
68 {
69 ((AbstractAggregator) processor).expireAggregation(groupId);
70 }
71 }
72 }
73
74 }