AddMessage() public method

Posts message to the queue using context properties.
public AddMessage ( Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage outboundMessage, System.TimeSpan ttl = null ) : void
outboundMessage Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage
ttl System.TimeSpan
return void
示例#1
0
        private void PostMessageToDestQueue(AzureDestinationQueueConnection destQueue, CloudQueueMessage outboundMessage, TimeSpan?ttl)
        {
            CloudQueueMessage outMsg = outboundMessage;

            try
            {
                destQueue.AddMessage(outMsg, ttl);
            }
            catch (StorageException ex)
            {
                const int queueNotFound = -2146233088;
                if (ex.HResult != queueNotFound) // Queue not found
                {
                    throw;
                }

                this.LogWarning("Queue \"{0}\" not found. Recreating.", destQueue.Queue.Name);
                // Re-create the queue and retry
                destQueue.Queue.CreateIfNotExists();
                destQueue.AddMessage(outMsg, ttl);
            }
        }
        private void PostMessageToDestQueue(AzureDestinationQueueConnection destQueue, CloudQueueMessage outboundMessage, TimeSpan? ttl)
        {
            CloudQueueMessage outMsg = outboundMessage;

            try
            {
                destQueue.AddMessage(outMsg, ttl);
            }
            catch(StorageException ex)
            {
                const int queueNotFound = -2146233088;
                if(ex.HResult != queueNotFound) // Queue not found
                    throw;

                this.LogWarning("Queue \"{0}\" not found. Recreating.", destQueue.Queue.Name);
                // Re-create the queue and retry
                destQueue.Queue.CreateIfNotExists();
                destQueue.AddMessage(outMsg, ttl);
            }
        }