Skip to content

[Persistence] If persistence write fails contents of batch to be persisted will be lost #115

@MendelMonteiro

Description

@MendelMonteiro

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();
            }
        }

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions