Interface OffsetUpdateListener


public interface OffsetUpdateListener
Listener invoked when the subscription offset is updated (on each publication and on initial subscribe). Use this to persist the offset to disk for recovery across process restarts.

Example usage:


 SubscriptionOptions opts = new SubscriptionOptions();
 opts.setRecoverable(true);
 opts.setOnOffsetUpdate((channel, position) -> {
     // Save offset and epoch to disk/database
     saveToFile(channel, position.getOffset(), position.getEpoch());
 });
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onOffsetUpdate(String channel, StreamPosition position)
    Called when the subscription offset is updated.
  • Method Details

    • onOffsetUpdate

      void onOffsetUpdate(String channel, StreamPosition position)
      Called when the subscription offset is updated.
      Parameters:
      channel - the channel name for the subscription
      position - the current stream position (offset + epoch)