org.apache.camel.processor
Class RedeliveryPolicy

java.lang.Object
  extended by org.apache.camel.processor.RedeliveryPolicy
All Implemented Interfaces:
Serializable, Cloneable

public class RedeliveryPolicy
extends Object
implements Cloneable, Serializable

The policy used to decide how many times to redeliver and the time between the redeliveries before being sent to a Dead Letter Channel

The default values is:

Setting the maximumRedeliveries to a negative value such as -1 will then always redeliver (unlimited). Setting the maximumRedeliveries to 0 will disable redelivery.

Version:
$Revision: 47354 $
See Also:
Serialized Form

Field Summary
protected  double backOffMultiplier
           
protected  double collisionAvoidanceFactor
           
protected  long initialRedeliveryDelay
           
protected  int maximumRedeliveries
           
protected  long maximumRedeliveryDelay
           
protected static Random randomNumberGenerator
           
protected  boolean useCollisionAvoidance
           
protected  boolean useExponentialBackOff
           
 
Constructor Summary
RedeliveryPolicy()
           
 
Method Summary
 RedeliveryPolicy backOffMultiplier(double multiplier)
          Enables exponential backoff and sets the multiplier used to increase the delay between redeliveries
 RedeliveryPolicy collisionAvoidancePercent(double collisionAvoidancePercent)
          Enables collision avoidence and sets the percentage used
 RedeliveryPolicy copy()
           
 double getBackOffMultiplier()
           
 double getCollisionAvoidanceFactor()
           
 short getCollisionAvoidancePercent()
           
 long getInitialRedeliveryDelay()
           
 int getMaximumRedeliveries()
           
 long getMaximumRedeliveryDelay()
           
protected static Random getRandomNumberGenerator()
           
 long getRedeliveryDelay(long previousDelay)
           
 RedeliveryPolicy initialRedeliveryDelay(long initialRedeliveryDelay)
          Sets the initial redelivery delay in milliseconds on the first redelivery
 boolean isUseCollisionAvoidance()
           
 boolean isUseExponentialBackOff()
           
 RedeliveryPolicy maximumRedeliveries(int maximumRedeliveries)
          Sets the maximum number of times a message exchange will be redelivered
 RedeliveryPolicy maximumRedeliveryDelay(long maximumRedeliveryDelay)
          Sets the maximum redelivery delay if using exponential back off.
 void setBackOffMultiplier(double backOffMultiplier)
          Sets the multiplier used to increase the delay between redeliveries if setUseExponentialBackOff(boolean) is enabled
 void setCollisionAvoidanceFactor(double collisionAvoidanceFactor)
          Sets the factor used for collision avoidence if enabled via setUseCollisionAvoidance(boolean)
 void setCollisionAvoidancePercent(double collisionAvoidancePercent)
          Sets the percentage used for collision avoidence if enabled via setUseCollisionAvoidance(boolean)
 void setInitialRedeliveryDelay(long initialRedeliveryDelay)
          Sets the initial redelivery delay in milliseconds on the first redelivery
 void setMaximumRedeliveries(int maximumRedeliveries)
          Sets the maximum number of times a message exchange will be redelivered.
 void setMaximumRedeliveryDelay(long maximumRedeliveryDelay)
          Sets the maximum redelivery delay if using exponential back off.
 void setUseCollisionAvoidance(boolean useCollisionAvoidance)
          Enables/disables collision avoidence which adds some randomization to the backoff timings to reduce contention probability
 void setUseExponentialBackOff(boolean useExponentialBackOff)
          Enables/disables exponential backof using the getBackOffMultiplier() to increase the time between retries
 boolean shouldRedeliver(int redeliveryCounter)
          Returns true if the policy decides that the message exchange should be redelivered
 long sleep(long redeliveryDelay)
          Calculates the new redelivery delay based on the last one then sleeps for the necessary amount of time
 String toString()
           
 RedeliveryPolicy useCollisionAvoidance()
          Enables collision avoidence which adds some randomization to the backoff timings to reduce contention probability
 RedeliveryPolicy useExponentialBackOff()
          Enables exponential backof using the getBackOffMultiplier() to increase the time between retries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

randomNumberGenerator

protected static transient Random randomNumberGenerator

maximumRedeliveries

protected int maximumRedeliveries

initialRedeliveryDelay

protected long initialRedeliveryDelay

maximumRedeliveryDelay

protected long maximumRedeliveryDelay

backOffMultiplier

protected double backOffMultiplier

useExponentialBackOff

protected boolean useExponentialBackOff

collisionAvoidanceFactor

protected double collisionAvoidanceFactor

useCollisionAvoidance

protected boolean useCollisionAvoidance
Constructor Detail

RedeliveryPolicy

public RedeliveryPolicy()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

copy

public RedeliveryPolicy copy()

shouldRedeliver

public boolean shouldRedeliver(int redeliveryCounter)
Returns true if the policy decides that the message exchange should be redelivered


sleep

public long sleep(long redeliveryDelay)
Calculates the new redelivery delay based on the last one then sleeps for the necessary amount of time


getRedeliveryDelay

public long getRedeliveryDelay(long previousDelay)

maximumRedeliveries

public RedeliveryPolicy maximumRedeliveries(int maximumRedeliveries)
Sets the maximum number of times a message exchange will be redelivered


initialRedeliveryDelay

public RedeliveryPolicy initialRedeliveryDelay(long initialRedeliveryDelay)
Sets the initial redelivery delay in milliseconds on the first redelivery


useCollisionAvoidance

public RedeliveryPolicy useCollisionAvoidance()
Enables collision avoidence which adds some randomization to the backoff timings to reduce contention probability


useExponentialBackOff

public RedeliveryPolicy useExponentialBackOff()
Enables exponential backof using the getBackOffMultiplier() to increase the time between retries


backOffMultiplier

public RedeliveryPolicy backOffMultiplier(double multiplier)
Enables exponential backoff and sets the multiplier used to increase the delay between redeliveries


collisionAvoidancePercent

public RedeliveryPolicy collisionAvoidancePercent(double collisionAvoidancePercent)
Enables collision avoidence and sets the percentage used


maximumRedeliveryDelay

public RedeliveryPolicy maximumRedeliveryDelay(long maximumRedeliveryDelay)
Sets the maximum redelivery delay if using exponential back off. Use -1 if you wish to have no maximum


getBackOffMultiplier

public double getBackOffMultiplier()

setBackOffMultiplier

public void setBackOffMultiplier(double backOffMultiplier)
Sets the multiplier used to increase the delay between redeliveries if setUseExponentialBackOff(boolean) is enabled


getCollisionAvoidancePercent

public short getCollisionAvoidancePercent()

setCollisionAvoidancePercent

public void setCollisionAvoidancePercent(double collisionAvoidancePercent)
Sets the percentage used for collision avoidence if enabled via setUseCollisionAvoidance(boolean)


getCollisionAvoidanceFactor

public double getCollisionAvoidanceFactor()

setCollisionAvoidanceFactor

public void setCollisionAvoidanceFactor(double collisionAvoidanceFactor)
Sets the factor used for collision avoidence if enabled via setUseCollisionAvoidance(boolean)


getInitialRedeliveryDelay

public long getInitialRedeliveryDelay()

setInitialRedeliveryDelay

public void setInitialRedeliveryDelay(long initialRedeliveryDelay)
Sets the initial redelivery delay in milliseconds on the first redelivery


getMaximumRedeliveries

public int getMaximumRedeliveries()

setMaximumRedeliveries

public void setMaximumRedeliveries(int maximumRedeliveries)
Sets the maximum number of times a message exchange will be redelivered. Setting a negative value will retry forever.


getMaximumRedeliveryDelay

public long getMaximumRedeliveryDelay()

setMaximumRedeliveryDelay

public void setMaximumRedeliveryDelay(long maximumRedeliveryDelay)
Sets the maximum redelivery delay if using exponential back off. Use -1 if you wish to have no maximum


isUseCollisionAvoidance

public boolean isUseCollisionAvoidance()

setUseCollisionAvoidance

public void setUseCollisionAvoidance(boolean useCollisionAvoidance)
Enables/disables collision avoidence which adds some randomization to the backoff timings to reduce contention probability


isUseExponentialBackOff

public boolean isUseExponentialBackOff()

setUseExponentialBackOff

public void setUseExponentialBackOff(boolean useExponentialBackOff)
Enables/disables exponential backof using the getBackOffMultiplier() to increase the time between retries


getRandomNumberGenerator

protected static Random getRandomNumberGenerator()


Copyright © 2008 IONA Open Source Community. All Rights Reserved.