In the following code when an exception is thrown the batch will still be cleared and the acks/msgs that were present will never be persisted.
I think we have two options, either leave the messages in the batch so that they are processed after the next delay or re-enqueue the entries in the batch so that they will be re-processed.
Any thoughts @ocoanet , @ltrzesniewski ?
private void PersistAndClearBatch(List<MatcherEntry> batch)
{
try
{
PersistBatch(batch);
}
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error happened");
_bus.Publish(new CustomProcessingFailed(GetType().FullName!, ex.ToString(), SystemDateTime.UtcNow));
}
finally
{
batch.Clear();
}
}