public static void ValidateSendMessageBatch(SendMessageBatchRequest request, SendMessageBatchResult response)
        {
            if (response != null && response.Successful != null && response.Successful.Count > 0)
            {
                Dictionary <string, SendMessageBatchRequestEntry> requestMessages = request.Entries.ToDictionary(entry => entry.Id, StringComparer.Ordinal);

                List <SendMessageBatchResultEntry> resultEntries = response.Successful;
                foreach (SendMessageBatchResultEntry entry in resultEntries)
                {
                    var    message = requestMessages[entry.Id];
                    string id      = entry.MessageId;

                    var body    = message.MessageBody;
                    var bodyMd5 = entry.MD5OfMessageBody;
                    ValidateMD5(body, id, bodyMd5);

                    var attributes    = message.MessageAttributes;
                    var attributesMd5 = entry.MD5OfMessageAttributes;
                    if (attributes != null && attributes.Count > 0 && !string.IsNullOrEmpty(attributesMd5))
                    {
                        ValidateMD5(attributes, id, attributesMd5);
                    }
                }
            }
        }
Beispiel #2
0
        private bool CollectErrors(SendMessageBatchResult result, IDictionary <Guid, T> map)
        {
            var errorIds = new HashSet <Guid>(result.BatchResultErrorEntry.Select(e => new Guid(e.Id)));

            foreach (var errorId in errorIds)
            {
                T @event;
                if (map.TryGetValue(errorId, out @event))
                {
                    Undeliverable.Enqueue(@event);
                }
            }
            return(false);
        }