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.DefaultMuleEvent;
10  import org.mule.api.MessagingException;
11  import org.mule.api.MuleMessage;
12  import org.mule.api.construct.FlowConstruct;
13  import org.mule.api.endpoint.ImmutableEndpoint;
14  import org.mule.session.DefaultMuleSession;
15  import org.mule.transport.jms.i18n.JmsMessages;
16  
17  public class MessageRedeliveredException extends MessagingException
18  {
19      /**
20       * Serial version
21       */
22      private static final long serialVersionUID = 9013890402770563931L;
23  
24      protected final transient ImmutableEndpoint endpoint;
25      
26      String messageId;
27      int redeliveryCount;
28      int maxRedelivery;
29  
30      public MessageRedeliveredException(String messageId, int redeliveryCount, int maxRedelivery, ImmutableEndpoint endpoint, FlowConstruct flow, MuleMessage muleMessage)
31      {        
32          super(JmsMessages.tooManyRedeliveries(messageId, redeliveryCount, maxRedelivery, endpoint), 
33              new DefaultMuleEvent(muleMessage, endpoint, new DefaultMuleSession(flow, endpoint.getMuleContext())));
34          this.messageId = messageId;
35          this.redeliveryCount = redeliveryCount;
36          this.maxRedelivery = maxRedelivery;
37          this.endpoint = endpoint;
38      }
39      
40      public String getMessageId()
41      {
42          return messageId;
43      }
44  
45      public int getRedeliveryCount()
46      {
47          return redeliveryCount;
48      }
49  
50      public int getMaxRedelivery()
51      {
52          return maxRedelivery;
53      }
54  
55      public ImmutableEndpoint getEndpoint()
56      {
57          return endpoint;
58      }
59  }