Aeron Archive replay last N messages

  Kiến thức lập trình

Suppose I have a live recording. When I start a service with business logic I want to read last N messages, if they are available. How to do it? I do the following:

long recordingPosition = archive.getRecordingPosition(recording.recordingId());
long startPosition = Math.max(recording.startPosition(), recordingPosition - N);

This code crashes with the following message:

ERROR - response for correlationId=63, error: 18480256 position not aligned to a data header, recordingId=122, sessionId=4304530350

I guess that my startPosition is not aligned to a message boundary. So the question is: how to determine a valid message boundary? I more or less don’t care if it is expressed in bytes or messages. I just want to avoid replaying the whole recording on startup.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT