View Javadoc

    1   package org.codehaus.xfire.transport.dead;
    2
    3   import org.apache.commons.logging.Log;
    4   import org.apache.commons.logging.LogFactory;
    5   import org.codehaus.xfire.MessageContext;
    6   import org.codehaus.xfire.XFireException;
    7   import org.codehaus.xfire.exchange.OutMessage;
    8   import org.codehaus.xfire.transport.AbstractChannel;
    9
    10  /***
    11   * A channel which does nothing except log when a message is sent from it.
    12   *
    13   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    14   */
    15  public class DeadLetterChannel
    16      extends AbstractChannel
    17  {
    18      private static final Log logger = LogFactory.getLog(DeadLetterChannel.class);
    19
    20      public DeadLetterChannel(DeadLetterTransport transport)
    21      {
    22          setTransport(transport);
    23      }
    24
    25      public void open()
    26          throws Exception
    27      {
    28      }
    29
    30      public void send(MessageContext context, OutMessage message)
    31          throws XFireException
    32      {
    33          Object body = message.getBody();
    34          if (body instanceof Exception)
    35              logger.error("Could not deliver message to " + message.getUri(), (Exception) body);
    36          else
    37              logger.error("Could not deliver message to " + message.getUri()+ ": " + body);
    38      }
    39
    40      public void close()
    41      {
    42      }
    43  }