예제 #1
0
        public async Task Should_remove_failedmessageretries_after_expiration_process_passes()
        {
            FailedMessageRetriesCountReponse failedMessageRetries = null;

            await Define <Context>()
            .WithEndpoint <FailingEndpointWithoutAudit>(b => b.When(async ctx =>
            {
                if (ctx.UniqueMessageId == null)
                {
                    return(false);
                }

                FailedMessage failedMessage = await this.TryGet <FailedMessage>($"/api/errors/{ctx.UniqueMessageId}");
                if (failedMessage == null)
                {
                    return(false);
                }
                ctx.FailureGroupId = failedMessage.FailureGroups.First().Id;

                return(true);
            }, async(bus, ctx) =>
            {
                ctx.AboutToSendRetry = true;
                await this.Post <object>($"/api/recoverability/groups/{ctx.FailureGroupId}/errors/retry");
            })
                                                        .DoNotFailOnErrorMessages())
            .Done(async ctx =>
            {
                if (ctx.Retried)
                {
                    // trigger cleanup
                    await this.Post <object>("/api/failederrors/forcecleanerrors");

                    failedMessageRetries = await this.TryGet <FailedMessageRetriesCountReponse>("/api/failedmessageretries/count");
                    return(failedMessageRetries.Count == 0);
                }

                return(false);
            })
            .Run();

            Assert.AreEqual(failedMessageRetries.Count, 0, "FailedMessageRetries not removed");
        }
예제 #2
0
        public async Task Should_remove_failedmessageretries_when_retrying_individual_messages()
        {
            FailedMessageRetriesCountReponse failedMessageRetries = null;

            await Define <Context>()
            .WithEndpoint <FailingEndpoint>(b => b.When(async ctx =>
            {
                if (ctx.UniqueMessageId == null)
                {
                    return(false);
                }

                FailedMessage failedMessage = await this.TryGet <FailedMessage>($"/api/errors/{ctx.UniqueMessageId}");
                if (failedMessage == null)
                {
                    return(false);
                }

                return(true);
            }, async(bus, ctx) =>
            {
                ctx.AboutToSendRetry = true;
                await this.Post <object>($"/api/errors/{ctx.UniqueMessageId}/retry");
            }).DoNotFailOnErrorMessages())
            .Done(async ctx =>
            {
                if (ctx.Retried)
                {
                    failedMessageRetries = await this.TryGet <FailedMessageRetriesCountReponse>("/api/failedmessageretries/count");

                    return(failedMessageRetries.Count == 0);
                }

                return(false);
            })
            .Run();

            Assert.AreEqual(failedMessageRetries.Count, 0, "FaileMessageRetries not removed");
        }