View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.routing.requestreply;
8   
9   import org.mule.api.MessagingException;
10  import org.mule.api.MuleEvent;
11  import org.mule.api.MuleException;
12  import org.mule.api.config.MuleProperties;
13  
14  /**
15   * ReplyToMessageProcessor for async flow.
16   * <p/>
17   * In synchronous flows will skip execution
18   */
19  public class ReplyToAsyncProcessor extends ReplyToMessageProcessor
20  
21  {
22  
23      public MuleEvent process(MuleEvent event) throws MuleException
24      {
25          if (shouldProcessEvent(event))
26          {
27              return super.process(event);
28          }
29          else
30          {
31              return processNext(event);
32          }
33      }
34  
35      protected boolean shouldProcessEvent(final MuleEvent event) throws MessagingException
36      {
37          Object messageProperty = event.getMessage().getInboundProperty(MuleProperties.MULE_FORCE_SYNC_PROPERTY);
38          boolean forceSync = Boolean.TRUE.equals(messageProperty);
39  
40          boolean hasResponse = event.getEndpoint().getExchangePattern().hasResponse();
41          boolean isTransacted = event.getEndpoint().getTransactionConfig().isTransacted();
42  
43          return !forceSync && !hasResponse && !isTransacted;
44      }
45  
46  }