Class StrandedItemsRegistry

java.lang.Object
de.hybris.platform.util.StrandedItemsRegistry

public class StrandedItemsRegistry extends Object
A class that allows to register an item as stranded - ex. a CronJob that has not updated the status or runningOnClusterNode fields but it's execution was finished (this could be a result of db outage or network problems).

Class allows to register such items and later check their state. The logic of selecting the items from registry to be check and the check itself is provided by StrandedItemsRegistry.StrandedItemsResolutionHandler object passed as a constructor argument of this class instance.

Since:
2011.0
  • Constructor Details

  • Method Details

    • markOnFailure

      public <T extends Item> void markOnFailure(T item, Consumer<T> logic)
      Executes the logic and in case of exception, the item is registered as stranded.
      Parameters:
      item - the item to be passed to consumer and registered in case of exception
      logic - the consumer of the item that should be executed
    • markOnFailure

      public <T extends Item> void markOnFailure(T item, Consumer<T> logic, Function<T,StrandedItemsRegistry.StrandedItemContext> itemContextFunction)
      Executes the logic and in case of exception, the item is registered as stranded.
      Parameters:
      item - the item to be passed to consumer and registered in case of exception
      logic - the consumer of the item that should be executed
      itemContextFunction - the function to provide the additional data for the resolution of this item
    • markStrandedItem

      public void markStrandedItem(PK pk)
      utility method that allows to add the given PK to the stranded items registry
      Parameters:
      pk -
    • getStrandedItems

      public Set<PK> getStrandedItems()
      Returns:
      the PKs of stranded items
    • getStrandedItemContext

      public Optional<StrandedItemsRegistry.StrandedItemContext> getStrandedItemContext(PK pk)
    • checkStrandedItems

      public void checkStrandedItems(int maxItemsToCheck)
      executes the check on stranded items
      Parameters:
      maxItemsToCheck - max count of items to check during the execution of this method. If lower than or equal 0 all registered items will be check with this call
      See Also:
      • StrandedItemsRegistry.StrandedItemsResolutionHandler.checkStrandedItems(StrandedItemsRegistry, Set)