1
2
3
4
5
6
7
8
9
10
11 package org.mule.processor;
12
13 import org.mule.api.MessagingException;
14 import org.mule.api.MuleEvent;
15 import org.mule.api.config.MuleProperties;
16 import org.mule.api.config.ThreadingProfile;
17 import org.mule.api.context.WorkManagerSource;
18
19
20
21
22
23
24
25 public class OptionalAsyncInterceptingMessageProcessor extends AsyncInterceptingMessageProcessor
26 {
27 public OptionalAsyncInterceptingMessageProcessor(WorkManagerSource workManagerSource)
28 {
29 super(workManagerSource);
30 }
31
32 @Deprecated
33 public OptionalAsyncInterceptingMessageProcessor(WorkManagerSource workManagerSource, boolean doThreading)
34 {
35 super(workManagerSource, doThreading);
36 }
37
38 public OptionalAsyncInterceptingMessageProcessor(ThreadingProfile threadingProfile,
39 String name,
40 int shutdownTimeout)
41 {
42 super(threadingProfile, name, shutdownTimeout);
43 }
44
45 @Override
46 protected boolean isProcessAsync(MuleEvent event) throws MessagingException
47 {
48 Object messageProperty = event.getMessage().getInboundProperty(MuleProperties.MULE_FORCE_SYNC_PROPERTY);
49 boolean forceSync = Boolean.TRUE.equals(messageProperty);
50
51 boolean hasResponse = event.getEndpoint().getExchangePattern().hasResponse();
52 boolean isTransacted = event.getEndpoint().getTransactionConfig().isTransacted();
53
54 return !forceSync && doThreading && !hasResponse && !isTransacted;
55 }
56
57 }