public async Task Should_store_body_regardless_of_the_body_size()
        {
            var fakeStorage = new FakeBodyStorage();
            // previously the max body storage default was larger than 100 KB

            var       enricher         = new BodyStorageFeature.BodyStorageEnricher(fakeStorage);
            const int ExpectedBodySize = 150000;
            var       body             = Encoding.UTF8.GetBytes(new string('a', ExpectedBodySize));

            await enricher.StoreErrorMessageBody(body, new Dictionary <string, string>(), new Dictionary <string, object>());

            Assert.AreEqual(ExpectedBodySize, fakeStorage.StoredBodySize, "Body should never be dropped for error messages");
        }
Exemple #2
0
        private void InnerHandle(TransportMessage message)
        {
            var metadata = new Dictionary <string, object>
            {
                ["MessageId"]           = message.Id,
                ["MessageIntent"]       = message.MessageIntent,
                ["HeadersForSearching"] = string.Join(" ", message.Headers.Values)
            };

            foreach (var enricher in enrichers)
            {
                enricher.Enrich(message.Headers, metadata);
            }

            bodyStorageEnricher.StoreErrorMessageBody(
                message.Body,
                message.Headers,
                metadata);

            var failureDetails = failedMessageFactory.ParseFailureDetails(message.Headers);

            var replyToAddress = message.ReplyToAddress == null ? null : message.ReplyToAddress.ToString();

            var processingAttempt = failedMessageFactory.CreateProcessingAttempt(
                message.Headers,
                metadata,
                failureDetails,
                message.MessageIntent,
                message.Recoverable,
                message.CorrelationId,
                replyToAddress);

            var groups = failedMessageFactory.GetGroups((string)metadata["MessageType"], failureDetails, processingAttempt);

            Store(message.Headers.UniqueId(), processingAttempt, groups);

            AnnounceFailedMessage(message.Headers, failureDetails);

            if (settings.ForwardErrorMessages)
            {
                TransportMessageCleaner.CleanForForwarding(message);
                forwarder.Send(message, new SendOptions(settings.ErrorLogQueue));
            }
        }