Ejemplo n.º 1
0
        public async Task Send()
        {
            var state = new State();
            IEndpointInstance endpoint = null;

            try
            {
                endpoint = await StartEndpoint(state).ConfigureAwait(false);

                var message = @"{ Property: 'Value' }";

                var headers = new Dictionary <string, string>
                {
                    { "NServiceBus.EnclosedMessageTypes", typeof(MessageToSend).FullName },
                    { "NServiceBus.MessageId", Guid.NewGuid().ToString() }
                };

                using (var client = ClientFactory.CreateSqsClient())
                {
                    await NativeSend.SendMessage(client, endpointName, message, headers)
                    .ConfigureAwait(false);
                }

                Assert.AreEqual("Value", await state.Signal.Task.ConfigureAwait(false));
            }
            finally
            {
                if (endpoint != null)
                {
                    await endpoint.Stop().ConfigureAwait(false);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task SendLarge()
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"sendlarge-{randomName}";
            var errorQueueName = $"sendlarge-{randomName}-error";

            var state = new State();
            IEndpointInstance endpoint = null;

            try
            {
                endpoint = await StartEndpoint(state, endpointName, errorQueueName).ConfigureAwait(false);

                var message = @"{ Property: 'Value' }";

                var headers = new Dictionary <string, string>
                {
                    { "NServiceBus.EnclosedMessageTypes", typeof(MessageToSend).FullName },
                    { "NServiceBus.MessageId", Guid.NewGuid().ToString() }
                };

                using (var s3Client = ClientFactory.CreateS3Client())
                    using (var client = ClientFactory.CreateSqsClient())
                    {
                        await NativeSend.SendLargeMessage(client, s3Client, endpointName, "test", SqsTransportConfigurationExtensions.S3BucketName, message, headers)
                        .ConfigureAwait(false);
                    }

                Assert.AreEqual("Value", await state.Signal.Task.ConfigureAwait(false));
            }
            finally
            {
                if (endpoint != null)
                {
                    await endpoint.Stop().ConfigureAwait(false);
                }

                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, includeRetries : true)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);
            }
        }