Interface OutboxInstanceRepository

  • All Implemented Interfaces:

    
    public interface OutboxInstanceRepository
    
                        

    Repository interface for managing outbox instance records.

    Provides operations for instance registration, heartbeat management, and cleanup of stale instances in a distributed outbox processing environment.

    Since:

    0.2.0

    Author:

    Roland Beisel

    • Constructor Detail

    • Method Detail

      • save

         abstract OutboxInstance save(OutboxInstance instance)

        Saves an instance to the repository.

        Parameters:
        instance - The instance to save
        Returns:

        The saved instance

      • findById

         abstract OutboxInstance findById(String instanceId)

        Finds an instance by its ID.

        Parameters:
        instanceId - The instance ID to search for
        Returns:

        The instance if found, null otherwise

      • findAll

         abstract List<OutboxInstance> findAll()

        Finds all instances in the repository.

        Returns:

        List of all instances ordered by creation time

      • findInstancesWithStaleHeartbeat

         abstract List<OutboxInstance> findInstancesWithStaleHeartbeat(OffsetDateTime cutoffTime)

        Finds instances with stale heartbeats (older than cutoff time).

        Parameters:
        cutoffTime - The cutoff time for stale heartbeats
        Returns:

        List of instances with heartbeats older than cutoff time

      • updateHeartbeat

         abstract Boolean updateHeartbeat(String instanceId, OffsetDateTime timestamp)

        Updates the heartbeat timestamp for an instance.

        Parameters:
        instanceId - The instance ID to update
        timestamp - The new heartbeat timestamp
        Returns:

        true if the update was successful, false if instance not found

      • updateStatus

         abstract Boolean updateStatus(String instanceId, OutboxInstanceStatus status, OffsetDateTime timestamp)

        Updates the status of an instance.

        Parameters:
        instanceId - The instance ID to update
        status - The new status
        timestamp - The timestamp of the status change
        Returns:

        true if the update was successful, false if instance not found

      • deleteById

         abstract Boolean deleteById(String instanceId)

        Deletes an instance by its ID.

        Parameters:
        instanceId - The instance ID to delete
        Returns:

        true if the deletion was successful, false if instance not found

      • deleteByStatus

         abstract Integer deleteByStatus(OutboxInstanceStatus status)

        Deletes all instances with the specified status.

        Parameters:
        status - The status of instances to delete
        Returns:

        The number of instances deleted

      • deleteStaleInstances

         abstract Integer deleteStaleInstances(OffsetDateTime cutoffTime)

        Deletes instances with stale heartbeats (cleanup operation).

        Parameters:
        cutoffTime - The cutoff time for stale heartbeats
        Returns:

        The number of instances deleted

      • count

         abstract Long count()

        Counts the total number of instances.

        Returns:

        The total count of instances

      • countByStatus

         abstract Long countByStatus(OutboxInstanceStatus status)

        Counts instances by status.

        Parameters:
        status - The status to count
        Returns:

        The count of instances with the specified status