Class ResetPosition

All Implemented Interfaces:
JsonType

public class ResetPosition extends Command
Command to forcibly reset the tracked position for a given consumer and message type.

Unlike StorePosition, which only allows the tracked index to move forward, this command allows setting a lower lastIndex, effectively rewinding the consumer’s position.

This is a powerful operation primarily intended for administrative or recovery scenarios. Common use cases include:

  • Reprocessing past messages after fixing a bug or applying a new projection
  • Resetting a consumer to rehydrate state (e.g. reloading an in-memory cache)
  • Clearing segment state after corruption or unexpected termination

Preferred Alternatives

For new consumers or reconfigured tracker instances, it is typically preferred to set the initial tracking index via ConsumerConfiguration or the @Consumer annotation. These approaches are safer and declarative, and avoid the potential side effects of resetting an active consumer.

Warning: Improper use may lead to duplicate processing. Ensure that consumers are idempotent or properly deduplicated before issuing a reset.

  • Constructor Details

    • ResetPosition

      public ResetPosition()
  • Method Details

    • routingKey

      public String routingKey()
      Returns a routing key used for partitioning the reset command by consumer and message type.
      Overrides:
      routingKey in class Command
      Returns:
      a routing key string, or null if not specified