Example #1
0
        public void Setup()
        {
            client = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();
            client.ServerTimeout = TimeSpan.FromSeconds(10);
            nativeQueue = client.GetQueueReference(QueueName);

            nativeQueue.CreateIfNotExists();
            nativeQueue.Clear();

            sender = new AzureMessageQueueSender
                        {
                            Client = client,
                            MessageSerializer = new JsonMessageSerializer(new MessageMapper())
                        };

            sender.Init(QueueName, true);

            receiver = new AzureMessageQueueReceiver
            {
                Client = client,
                MessageSerializer = new JsonMessageSerializer(new MessageMapper()),
            };

            receiver.Init(QueueName, true);
        }
Example #2
0
        public void CloudQueueClearMessage()
        {
            string     name  = GenerateNewQueueName();
            CloudQueue queue = DefaultQueueClient.GetQueueReference(name);

            queue.Create();

            string            msgContent = Guid.NewGuid().ToString("N");
            CloudQueueMessage message    = new CloudQueueMessage(msgContent);

            queue.AddMessage(message);
            CloudQueueMessage receivedMessage1 = queue.PeekMessage();

            Assert.IsTrue(receivedMessage1.AsString == message.AsString);
            queue.Clear();
            Assert.IsNull(queue.PeekMessage());
            queue.Delete();
        }
        public void Init(Address address, bool transactional)
        {
            useTransactions = transactional;

            var queueName = AzureMessageQueueUtils.GetQueueName(address);

            azureQueue = Client.GetQueueReference(queueName);
            azureQueue.CreateIfNotExists();

            if (PurgeOnStartup)
            {
                azureQueue.Clear();
            }
        }