/// <summary> /// Gets the outgoing messages for the incoming message with the given ID /// </summary> public IEnumerable <OutgoingMessage> GetOutgoingMessages(string messageId) { var outgoingMessages = OutgoingMessages.FirstOrDefault(o => o.MessageId == messageId); return(outgoingMessages != null ? outgoingMessages.MessagesToSend : Enumerable.Empty <OutgoingMessage>()); }
OutgoingMessages GetOrCreate(string messageId) { _handledMessageIds.Add(messageId); var outgoingMessages = _outgoingMessages.FirstOrDefault(o => o.MessageId == messageId); if (outgoingMessages != null) return outgoingMessages; outgoingMessages = new OutgoingMessages(messageId, new List<OutgoingMessage>()); _outgoingMessages.Add(outgoingMessages); return outgoingMessages; }
/// <summary> /// Creates the idempotency data object, initializing it with the given list of outgoing message lists and record of handled message IDs /// </summary> public IdempotencyData(IEnumerable <OutgoingMessages> outgoingMessages = null, IEnumerable <string> handledMessageIds = null) { if (outgoingMessages != null) { OutgoingMessages.AddRange(outgoingMessages); } if (handledMessageIds != null) { foreach (var id in handledMessageIds) { HandledMessageIds.Add(id); } } }
OutgoingMessages GetOrCreate(string messageId) { HandledMessageIds.Add(messageId); var outgoingMessages = OutgoingMessages.FirstOrDefault(o => o.MessageId == messageId); if (outgoingMessages != null) { return(outgoingMessages); } outgoingMessages = new OutgoingMessages(messageId, new List <OutgoingMessage>()); OutgoingMessages.Add(outgoingMessages); return(outgoingMessages); }