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