View Javadoc

1   /*
2    * $Id: LoggingCatchAllStrategy.java 19191 2010-08-25 21:05:23Z tcarlson $
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;
12  
13  import org.mule.DefaultMuleEvent;
14  import org.mule.api.MuleEvent;
15  import org.mule.api.routing.RoutingException;
16  
17  import org.apache.commons.logging.Log;
18  import org.apache.commons.logging.LogFactory;
19  
20  /**
21   * <code>LoggingCatchAllStrategy</code> is a simple strategy that only logs any
22   * events not caught by the router associated with this strategy. This should
23   * <b>not</b> be used in production unless it is acceptable for events to be lost.
24   */
25  
26  public class LoggingCatchAllStrategy extends AbstractCatchAllStrategy
27  {
28      private static final Log logger = LogFactory.getLog(DefaultMuleEvent.class);
29  
30      public MuleEvent doCatchMessage(MuleEvent event) throws RoutingException
31      {
32          logger.warn(String.format("Message was not dispatched. No routing path was defined for it. Message: %s", event.getMessage()));
33          return event;
34      }
35  }