コード例 #1
0
        public override async Task Successful(OutgoingMessageBatch outgoing)
        {
            try
            {
                using (var conn = _store.Tenancy.Default.CreateConnection())
                {
                    await conn.OpenAsync(_cancellation);

                    await conn.CreateCommand($"delete from {_marker.Outgoing} where id = ANY(:idlist)")
                    .With("idlist", outgoing.Messages.Select(x => x.Id).ToArray(),
                          NpgsqlDbType.Array | NpgsqlDbType.Uuid)
                    .ExecuteNonQueryAsync(_cancellation);
                }
            }
            catch (Exception e)
            {
                _logger.LogException(e, message: "Error trying to delete outgoing envelopes after a successful batch send");
                foreach (var envelope in outgoing.Messages)
                {
                    _retries.DeleteOutgoing(envelope);
                }
            }
        }