public async Task The_handlers_should_be_invoked_and_process_successfully() { var receivedMessages = await GenerateAndReceiveSQSEvent <SuccessMessage>(3); var context = new TestContext(); var endpoint = new AwsLambdaSQSEndpoint(ctx => { var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName); var transport = configuration.Transport; transport.ClientFactory(CreateSQSClient); var advanced = configuration.AdvancedConfiguration; advanced.SendFailedMessagesTo(ErrorQueueName); advanced.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context)); return(configuration); }); await endpoint.Process(receivedMessages, null); Assert.AreEqual(receivedMessages.Records.Count, context.HandlerInvokationCount); var messagesInErrorQueueCount = await CountMessagesInErrorQueue(); Assert.AreEqual(0, messagesInErrorQueueCount); }
public async Task The_messages_should_forward_to_error_queue_by_default() { var receivedMessages = await GenerateAndReceiveSQSEvent <AlwaysFailsMessage>(3); var context = new TestContext(); var endpoint = new AwsLambdaSQSEndpoint(ctx => { var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName); var transport = configuration.Transport; transport.ClientFactory(CreateSQSClient); var advanced = configuration.AdvancedConfiguration; advanced.SendFailedMessagesTo(ErrorQueueName); advanced.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context)); return(configuration); }); await endpoint.Process(receivedMessages, null); var messagesInErrorQueueCount = await CountMessagesInErrorQueue(); Assert.AreEqual(receivedMessages.Records.Count, messagesInErrorQueueCount, "Error queue count mismatch"); Assert.AreEqual(messagesInErrorQueueCount * 6, context.HandlerInvokationCount, "Immediate/Delayed Retry count mismatch"); }
public async Task The_message_should_be_received() { var receivedMessages = await GenerateAndReceiveSQSEvent <MessageThatTriggersASentMessage>(1); var context = new TestContext(); var destinationEndpointName = $"{QueueNamePrefix}DestinationEndpoint"; RegisterQueueNameToCleanup(destinationEndpointName); var destinationConfiguration = new EndpointConfiguration(destinationEndpointName); destinationConfiguration.UsePersistence <InMemoryPersistence>(); var destinationTransport = destinationConfiguration.UseTransport <SqsTransport>(); destinationTransport.ClientFactory(CreateSQSClient); destinationConfiguration.SendFailedMessagesTo(ErrorQueueName); destinationConfiguration.EnableInstallers(); destinationConfiguration.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context)); var destinationEndpoint = await Endpoint.Start(destinationConfiguration); var endpoint = new AwsLambdaSQSEndpoint(ctx => { var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName); var transport = configuration.Transport; transport.ClientFactory(CreateSQSClient); var routing = transport.Routing(); routing.RouteToEndpoint(typeof(SentMessage), destinationEndpointName); var advanced = configuration.AdvancedConfiguration; advanced.SendFailedMessagesTo(ErrorQueueName); advanced.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context)); return(configuration); }); await endpoint.Process(receivedMessages, null); await context.MessageReceived.Task; await destinationEndpoint.Stop(); var messagesInErrorQueueCount = await CountMessagesInErrorQueue(); Assert.AreEqual(0, messagesInErrorQueueCount, "Error queue count mismatch"); }