public void LogErrorReport(ErrorReport report) { if (!_settings.PersistDeadLetterEnvelopes) { return; } _logErrorReportBatching.SendAsync(report); }
public BatchedSender(Uri destination, ISenderProtocol protocol, CancellationToken cancellation, ITransportLogger logger) { Destination = destination; _protocol = protocol; _cancellation = cancellation; _logger = logger; _sender = new ActionBlock <OutgoingMessageBatch>(SendBatch, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1, CancellationToken = _cancellation, BoundedCapacity = DataflowBlockOptions.Unbounded }); _sender.Completion.ContinueWith(x => { if (x.IsFaulted) { _logger.LogException(x.Exception); } }, _cancellation); _serializing = new ActionBlock <Envelope>(async e => { try { await _batching.SendAsync(e); } catch (Exception ex) { _logger.LogException(ex, message: $"Error while trying to serialize envelope {e}"); } }, new ExecutionDataflowBlockOptions { CancellationToken = _cancellation, BoundedCapacity = DataflowBlockOptions.Unbounded }); _serializing.Completion.ContinueWith(x => { if (x.IsFaulted) { _logger.LogException(x.Exception); } }, _cancellation); _batchWriting = new TransformBlock <Envelope[], OutgoingMessageBatch>( envelopes => { var batch = new OutgoingMessageBatch(Destination, envelopes); _queued += batch.Messages.Count; return(batch); }, new ExecutionDataflowBlockOptions { BoundedCapacity = DataflowBlockOptions.Unbounded, MaxDegreeOfParallelism = 10, CancellationToken = _cancellation }); _batchWriting.Completion.ContinueWith(x => { if (x.IsFaulted) { _logger.LogException(x.Exception); } }, _cancellation); _batchWriting.LinkTo(_sender); _batching = new BatchingBlock <Envelope>(200, _batchWriting, _cancellation); _batching.Completion.ContinueWith(x => { if (x.IsFaulted) { _logger.LogException(x.Exception); } }, _cancellation); }
public void ScheduleExecution(Envelope envelope) { _scheduleIncomingBatching.SendAsync(envelope); }
public void DeleteOutgoing(Envelope envelope) { _deleteOutgoingBatching.SendAsync(envelope); }
public void DeleteIncoming(Envelope envelope) { _deleteIncomingBatching.SendAsync(envelope); }
public void Start(ISenderCallback callback) { _callback = callback; _sender = new ActionBlock <OutgoingMessageBatch>(SendBatch, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1, CancellationToken = _cancellation, BoundedCapacity = DataflowBlockOptions.Unbounded }); _sender.Completion.ContinueWith(x => { if (x.IsFaulted) { // TODO -- need to restart things!!! _logger.LogException(x.Exception); } }, _cancellation); _serializing = new ActionBlock <Envelope>(async e => { try { e.EnsureData(); await _batching.SendAsync(e); } catch (Exception ex) { _logger.LogException(ex, message: $"Error while trying to serialize envelope {e}"); } }, new ExecutionDataflowBlockOptions { CancellationToken = _cancellation, BoundedCapacity = DataflowBlockOptions.Unbounded }); _serializing.Completion.ContinueWith(x => { if (x.IsFaulted) { // TODO -- need to restart things!!! _logger.LogException(x.Exception); } }, _cancellation); _batchWriting = new TransformBlock <Envelope[], OutgoingMessageBatch>( envelopes => { var batch = new OutgoingMessageBatch(Destination, envelopes); _queued += batch.Messages.Count; return(batch); }, new ExecutionDataflowBlockOptions { BoundedCapacity = DataflowBlockOptions.Unbounded, MaxDegreeOfParallelism = 10 }); _batchWriting.Completion.ContinueWith(x => { if (x.IsFaulted) { // TODO -- need to restart things!!! _logger.LogException(x.Exception); } }, _cancellation); _batchWriting.LinkTo(_sender); _batching = new BatchingBlock <Envelope>(200, _batchWriting, _cancellation); _batching.Completion.ContinueWith(x => { if (x.IsFaulted) { // TODO -- need to restart things!!! _logger.LogException(x.Exception); } }, _cancellation); }