예제 #1
0
        public async Task SendBatchMessages()
        {
            using (var queue = ServiceBusEntityFactory.DeleteAndCreateQueue("integration-queue-sender"))
            {
                var id1 = Guid.NewGuid().ToString();
                var id2 = Guid.NewGuid().ToString();
                var id3 = Guid.NewGuid().ToString();

                var sender = new QueueMessageSender(queue.Client);
                await sender.SendBatchAsync(new []
                {
                    new BrokeredMessage {
                        MessageId = id1
                    },
                    new BrokeredMessage {
                        MessageId = id2
                    },
                    new BrokeredMessage {
                        MessageId = id3
                    }
                });

                var messages = queue.Client.ReceiveBatch(250).ToArray();
                Assert.Equal(3, messages.Length);
                Assert.True(messages.Any(m => m.MessageId == id1));
                Assert.True(messages.Any(m => m.MessageId == id2));
                Assert.True(messages.Any(m => m.MessageId == id3));
            }
        }