Package io.namastack.outbox
Class OutboxInstanceRegistry
-
- All Implemented Interfaces:
public final class OutboxInstanceRegistryRegistry service for managing outbox processor instances.
Handles instance registration, heartbeat management for horizontal scaling across multiple physical application instances.
- Since:
0.2.0
Roland Beisel
-
-
Constructor Summary
Constructors Constructor Description OutboxInstanceRegistry(OutboxInstanceRepository instanceRepository, OutboxProperties properties, Clock clock)
-
Method Summary
Modifier and Type Method Description final StringgetCurrentInstanceId()Gets the current instance ID. final List<OutboxInstance>getActiveInstances()Gets all currently active instances. final Set<String>getActiveInstanceIds()Gets all active instance IDs. final BooleanisInstanceActive(String instanceId)Checks if a specific instance is active. final LonggetActiveInstanceCount()Gets the count of active instances. final UnitregisterInstance()Registers this instance on startup. final UnitperformHeartbeatAndCleanup()Sends heartbeat and cleans up stale instances. final UnitgracefulShutdown()Performs graceful shutdown of this instance. final UnitdetectNewInstances()Detects new instances that joined. -
-
Constructor Detail
-
OutboxInstanceRegistry
OutboxInstanceRegistry(OutboxInstanceRepository instanceRepository, OutboxProperties properties, Clock clock)
- Parameters:
instanceRepository- Repository for persisting instance dataproperties- Configuration properties for outbox functionalityclock- Clock for time-based operations
-
-
Method Detail
-
getCurrentInstanceId
final String getCurrentInstanceId()
Gets the current instance ID.
-
getActiveInstances
final List<OutboxInstance> getActiveInstances()
Gets all currently active instances.
-
getActiveInstanceIds
final Set<String> getActiveInstanceIds()
Gets all active instance IDs.
-
isInstanceActive
final Boolean isInstanceActive(String instanceId)
Checks if a specific instance is active.
-
getActiveInstanceCount
final Long getActiveInstanceCount()
Gets the count of active instances.
-
registerInstance
@PostConstruct() final Unit registerInstance()
Registers this instance on startup.
-
performHeartbeatAndCleanup
@Scheduled(fixedRateString = "${outbox.instance.heartbeat-interval-seconds:5}000") final Unit performHeartbeatAndCleanup()Sends heartbeat and cleans up stale instances.
-
gracefulShutdown
final Unit gracefulShutdown()
Performs graceful shutdown of this instance.
-
detectNewInstances
@Scheduled(fixedRateString = "${outbox.instance.new-instance-detection-interval-seconds:10}000") final Unit detectNewInstances()Detects new instances that joined.
-
-
-
-