org.instrumentmiddleware.cima.transport.delivery.impl
Class InfiniteTryDeliveryStrategy

java.lang.Object
  extended by org.instrumentmiddleware.cima.transport.delivery.impl.AbstractDeliveryStrategy
      extended by org.instrumentmiddleware.cima.transport.delivery.impl.InfiniteTryDeliveryStrategy
All Implemented Interfaces:
java.util.concurrent.Callable<org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel>, IDeliveryStrategy

public class InfiniteTryDeliveryStrategy
extends AbstractDeliveryStrategy

InfiniteTryDeliveryStrategy will continue to try delivering as long as it can. Successful delivery is determined by receiving a response from the from the transport provider. Note that receipt of parcel that indicates failure (in the parcel response) actually indicates successful delivery. Only parcels of type "plugin" should be sent using this strategy, as it may be inappropriate to retry sending other parcel types (eg, subscription).

Author:
andrew

Field Summary
 
Fields inherited from class org.instrumentmiddleware.cima.transport.delivery.impl.AbstractDeliveryStrategy
executor, log, parcel, transportManager
 
Constructor Summary
InfiniteTryDeliveryStrategy(ITransportManager transportManager, java.util.concurrent.ExecutorService executor)
          Initialise this delivery strategy.
 
Method Summary
 org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel deliver()
          Commence delivery.
 void setDelay(long delay)
          Sets the delay between delivery attempts.
 
Methods inherited from class org.instrumentmiddleware.cima.transport.delivery.impl.AbstractDeliveryStrategy
call, canRun, setRegisteredParcel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InfiniteTryDeliveryStrategy

public InfiniteTryDeliveryStrategy(ITransportManager transportManager,
                                   java.util.concurrent.ExecutorService executor)
                            throws java.lang.Exception
Initialise this delivery strategy. A valid transport manager is required to correctly construct this object.

Parameters:
transportManager -
Throws:
java.lang.Exception - if the required transport manager is not valid
See Also:
AbstractDeliveryStrategy(ITransportManager)
Method Detail

setDelay

public void setDelay(long delay)
Sets the delay between delivery attempts.

Parameters:
delay -

deliver

public org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel deliver()
Commence delivery. This method should not be called directly, but should be called as a result of starting a new thread. Initially, a check is made to see if there is enough information to attempt delivery, if not this method returns immediately. For each recipient, an attempt is made to deliver the parcel only if an appropriate endpoint and transport provider are available. If not, that recipient is removed from the list of recipients and delivery continues. If delivery to a recipient fails, the there is a pause of at least delay seconds before another delivery attempt is made. This continues indefinitely. There is no clean way to stop this delivery strategy at the moment.



Copyright © 2008. All Rights Reserved.