com.ibm.commerce.subscription.scheduler.actions

Class AbstractSubscriptionScheduledActionCmdImpl

  • All Implemented Interfaces:
    com.ibm.commerce.command.CacheableECCommand, ECCommand, ECTargetableCommand, TaskCommand, SubscriptionScheduledActionCmd, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable
    Direct Known Subclasses:
    SubscriptionCancelScheduledActionImpl, SubscriptionCreateChildOrderSchedulerCmdImpl, SubscriptionExpireScheduledActionImpl


    public abstract class AbstractSubscriptionScheduledActionCmdImpl
    extends TaskCommandImpl
    implements SubscriptionScheduledActionCmd
    This abstract task command is used as base for any scheduled action command which would use multiple transient states during the processing of a scheduled action. This class moves the subscription to a processing state at the beginning and allow the child class to process the subscription state. The child class can then control the flow through various states of processing. For each state a new transaction is created and committed when the child class requests a change in state. If at any state, the transaction fails or the child class throws up an uncaught exception, the state is retried. For each state, the child class decides the retry count. If the processing cannot be retrieved after the retries, the command is forced into a recovery mode where the child class is expected to recover or roll back from all the processing that is committed so far.
    The important methods for a child class are:
    • processSubscriptionState
    • updateSubscriptionState
    • handleStateRetry
    • recoverState
    • getMaximumNumberOfRetriesForState
    See Also:
    Serialized Form
    • Field Detail

      • MAX_RETRIES_FOR_SUBSCRIPTION_STATE_UPDATE

        public static final int MAX_RETRIES_FOR_SUBSCRIPTION_STATE_UPDATE
        Constant representing the number of times a state update needs to be retried before failing.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractSubscriptionScheduledActionCmdImpl

        public AbstractSubscriptionScheduledActionCmdImpl()
    • Method Detail

      • initialize

        public void initialize()
                        throws java.lang.Exception
        This method initializes the task command.By default this method does nothing. This method is called before execution.
        Specified by:
        initialize in interface SubscriptionScheduledActionCmd
        Throws:
        java.lang.Exception
      • setScheduledAction

        public void setScheduledAction(java.lang.Long scheduledActionID)
        Sets the Subscrschjobs object instance which represents the scheduled action being executed.
        Specified by:
        setScheduledAction in interface SubscriptionScheduledActionCmd
        Parameters:
        scheduledActionID - The unique ID of the scheduled action being carried out by the command.
      • setSubscriptionId

        public void setSubscriptionId(java.lang.Long subscriptionId)
        Sets the subscription ID being processed.
        Specified by:
        setSubscriptionId in interface SubscriptionScheduledActionCmd
        Parameters:
        subscriptionId - The unique ID of the subscription being processed.
      • getSubscriptionId

        public java.lang.Long getSubscriptionId()
        This method returns the unique ID of the subscription being processed.
        Returns:
        The unique ID of the subscription.
      • performExecute

        public final void performExecute()
                                  throws ECException
        This method executes the business logic required for carrying out the scheduled action. This method triggers the state processing and tracks the state changes through the execution of the scheduled action.

        Any failures during processing would trigger the recovery mechanism after retries. After the recovery mechanism is completed, the method throws a SubscriptionSystemException with _ERR_EXECUTION_OF_SCHEDULED_ACTION_FAILED as the message key.

        Once the scheduled action is processed successfully through the transient states, this method resets the transient state in the subscription table and updates the subscription to the final state as returned by the getFinalStateForSubscription method. Any failure while updating the subscription state after retries would result in a SubscriptionSystemException with _ERR_EXECUTION_OF_SCHEDULED_ACTION_FAILED_SUCCESSFULLY.

        Specified by:
        performExecute in interface ECCommand
        Specified by:
        performExecute in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        performExecute in class AbstractECTargetableCommand
        Throws:
        ECException - When an exception occurs.
      • setExeceptionForFailure

        public void setExeceptionForFailure(java.lang.Throwable cause)
        This method sets the exception which caused the failure for this command.
        Specified by:
        setExeceptionForFailure in interface SubscriptionScheduledActionCmd
        Parameters:
        cause - The exception which caused the failure.