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