View Javadoc

1   /*
2    * $Id: RedeliveryHandler.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.transport.jms;
12  
13  import org.mule.api.MuleException;
14  
15  import javax.jms.JMSException;
16  import javax.jms.Message;
17  
18  /**
19   * <code>RedeliveryHandler</code> is used to control how redelivered messages are
20   * processed by a connector. Typically, a messsage will be re-tried once or twice
21   * before throwing an exception. Then the exception strategy on the connector can be
22   * used to forward the message to a JMS queue or log the failure.
23   */
24  public interface RedeliveryHandler
25  {
26  
27      /**
28       * The connector associated with this handler is set before
29       * <code>handleRedelivery()</code> is called
30       * 
31       * @param connector the connector associated with this handler
32       */
33      public void setConnector(JmsConnector connector);
34  
35      /**
36       * Process the redelivered message. If the JMS receiver should process the
37       * message, it should be returned. Otherwise the connector should throw a
38       * {@link MessageRedeliveredException} to indicate that the message should be
39       * handled by the connector's exception handler.
40       * 
41       * @param message the redelivered message
42       * @throws JMSException if properties cannot be read from the JMSMessage
43       * @throws MessageRedeliveredException should be thrown if the message should be
44       *             handled by the connection exception handler
45       * @throws MuleException if there is a problem reading or proessing the
46       *             message
47       */
48      public void handleRedelivery(Message message) throws JMSException, MuleException;
49  
50  }