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.outbound;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.api.MuleMessage;
11  
12  /**
13   * Defines a {@link AbstractSequenceRouter} that stops the routing of a given
14   * message when a synchronous endpoint has returned a null or an exception
15   * message.
16   * <p/>
17   * Asynchronous endpoints are managed as in the {@link AbstractSequenceRouter}.
18   */
19  public class SequenceRouter extends AbstractSequenceRouter
20  {
21  
22      /**
23       * Determines if the routing should continue after receiving a given
24       * response from an synchronous endpoint.
25       *
26       * @param event the last received response event
27       * @return true if the message is not null and is not an exception message.
28       *         False otherwise.
29       */
30      @Override
31      protected boolean continueRoutingMessageAfter(MuleEvent event)
32      {
33          boolean result = true;
34  
35          MuleMessage muleMessage = event.getMessage();
36  
37          if (muleMessage == null || muleMessage.getExceptionPayload() != null)
38          {
39              logger.warn("Sequence router will stop routing current message");
40              result = false;
41          }
42  
43          return result;
44      }
45  }