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