View Javadoc

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