View Javadoc

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