View Javadoc

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