Package io.github.centrifugal.centrifuge
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 TypeMethodDescriptionvoidonOffsetUpdate(String channel, StreamPosition position) Called when the subscription offset is updated.
-
Method Details
-
onOffsetUpdate
Called when the subscription offset is updated.- Parameters:
channel- the channel name for the subscriptionposition- the current stream position (offset + epoch)
-