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 Send()
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"send-{randomName}";
            var errorQueueName = $"send-{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 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);
                }

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

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