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