private void groupMessages(Envelope[] messages) { var groups = messages.GroupBy(x => x.Destination); foreach (var @group in groups) { var batch = new OutgoingMessageBatch(@group.Key, @group); _sender.Post(batch); } }
private async Task sendBatch(OutgoingMessageBatch batch) { try { await _protocol.SendBatch(_callback, batch); } catch (Exception e) { batchSendFailed(batch, e); } }
public async Task SendBatch(ISenderCallback callback, OutgoingMessageBatch batch) { using (var client = new TcpClient()) { await connect(client, batch.Destination) .TimeoutAfter(5000); using (var stream = client.GetStream()) { await WireProtocol.Send(stream, batch, callback).TimeoutAfter(5000); } } }
void ISenderCallback.TimedOut(OutgoingMessageBatch outgoing) { processRetry(outgoing); }
void ISenderCallback.Successful(OutgoingMessageBatch outgoing) { Persistence.RemoveOutgoing(outgoing.Messages); }
void ISenderCallback.ProcessingFailure(OutgoingMessageBatch outgoing, Exception exception) { processRetry(outgoing); }
void ISenderCallback.QueueDoesNotExist(OutgoingMessageBatch outgoing) { processRetry(outgoing); }
void ISenderCallback.SerializationFailure(OutgoingMessageBatch outgoing) { processRetry(outgoing); }
private void batchSendFailed(OutgoingMessageBatch batch, Exception exception) { _callback.ProcessingFailure(batch, exception); }
public void PersistBasedOnSentAttempts(OutgoingMessageBatch batch, int maxAttempts) { }