Beispiel #1
0
        /// <summary>
        /// Get delegate for enqueuing messages asynchronously to named queue.
        /// </summary>
        /// <param name="queueName">Queue name.</param>
        /// <returns>Delegate for enqueuing message asynchronously.</returns>
        public Action <string> GetEnqueueMessageCallback(SqsQueueName queueName)
        {
repeat:
            SqsQueueDelayedSendClient queue;
            var directory = _directory;

            if (!directory.TryGetValue(queueName.Value, out queue))
            {
                var newDirectory = new Dictionary <string, SqsQueueDelayedSendClient>(directory);
                newDirectory[queueName.Value] = queue = new SqsQueueDelayedSendClient(_client, queueName, _timerFactory);
                if (!SysUtil.CAS(ref _directory, directory, newDirectory))
                {
                    goto repeat;
                }
            }
            return(queue.EnqueueMessage);
        }
Beispiel #2
0
 /// <summary>
 /// Get delegate for enqueuing messages asynchronously to named queue.
 /// </summary>
 /// <param name="queueName">Queue name.</param>
 /// <returns>Delegate for enqueuing message asynchronously.</returns>
 public Action<string> GetEnqueueMessageCallback(SqsQueueName queueName)
 {
     repeat:
     SqsQueueDelayedSendClient queue;
     var directory = _directory;
     if(!directory.TryGetValue(queueName.Value, out queue)) {
         var newDirectory = new Dictionary<string, SqsQueueDelayedSendClient>(directory);
         newDirectory[queueName.Value] = queue = new SqsQueueDelayedSendClient(_client, queueName, _timerFactory);
         if(!SysUtil.CAS(ref _directory, directory, newDirectory)) {
             goto repeat;
         }
     }
     return queue.EnqueueMessage;
 }