View Javadoc

1   /*
2    * $Id: DefaultFlowProcessingStrategy.java 22864 2011-09-05 17:18:46Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.construct.flow;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.config.ThreadingProfile;
15  import org.mule.config.QueueProfile;
16  import org.mule.processor.AsyncInterceptingMessageProcessor;
17  import org.mule.processor.LaxSedaStageInterceptingMessageProcessor;
18  import org.mule.processor.strategy.QueuedAsynchronousProcessingStrategy;
19  
20  /**
21   * This processing strategy uses the 'queued-asynchronous' strategy where possible, but if an event is
22   * synchronous it processes it synchronously rather than failing.
23   */
24  public class DefaultFlowProcessingStrategy extends QueuedAsynchronousProcessingStrategy
25  {
26  
27      @Override
28      protected AsyncInterceptingMessageProcessor createAsyncMessageProcessor(StageNameSource nameSource,
29                                                                              MuleContext muleContext)
30      {
31          Integer timeout = queueTimeout != null ? queueTimeout : muleContext.getConfiguration()
32              .getDefaultQueueTimeout();
33  
34          initQueueStore(muleContext);
35  
36          QueueProfile queueProfile = new QueueProfile(maxQueueSize, queueStore);
37          ThreadingProfile threadingProfile = createThreadingProfile(muleContext);
38          String stageName = nameSource.getName();
39          return new LaxSedaStageInterceptingMessageProcessor(getThreadPoolName(stageName, muleContext),
40              stageName, queueProfile, timeout, threadingProfile, queueStatistics, muleContext);
41      }
42  
43  }