I’m working on my exporter (NATS/NATS Streaming), implementing Exporter.export() method.
In my case the order of exports’ completions may be different than the order of records being received.
When should I call Controller#updateLastExportedRecordPosition?
Javadoc on Exporter interface says:
Exporter.export(Record record): Called at least once for every record to be exported. Once a record is guaranteed to have been exported, implementations should call Controller#updateLastExportedRecordPosition to signal that this record should not be received here ever again.
But I see two contradicting approaches on when Controller#updateLastExportedRecordPosition must be called:
- On each successfully exported record, meaning the order of records (their positions) does not matter
- On the last successfully exported record in the order records received, meaning that all the calls of Controller#updateLastExportedRecordPosition must be with monotonically increasing positions.
What approach is correct?
P.S.: my biggest concern is not to lose failed to export record with position 1 after I signaled updateLastExportedRecordPosition(2)