Container for the parameters to the PurgeQueue operation. Deletes the messages in a queue specified by the QueueURL parameter.

When you use the PurgeQueue action, you can't retrieve a message deleted from a queue.

When you purge a queue, the message deletion process takes up to 60 seconds. All messages sent to the queue before calling the PurgeQueue action are deleted. Messages sent to the queue while it is being purged might be deleted. While the queue is being purged, messages sent to the queue before PurgeQueue is called might be received, but are deleted within the next minute.

Наследование: AmazonSQSRequest
        public async Task <PurgeQueueResponse> PurgeQueueAsync(string queueUrl,
                                                               CancellationToken cancellationToken = default)
        {
            this.Logger.LogDebug($"[{nameof(this.PurgeQueueAsync)}]");

            this.Logger.LogTrace(JsonConvert.SerializeObject(new { queueUrl }));

            if (string.IsNullOrWhiteSpace(queueUrl))
            {
                throw new ArgumentNullException(nameof(queueUrl));
            }

            var request = new Amazon.SQS.Model.PurgeQueueRequest
            {
                QueueUrl = queueUrl,
            };

            this.Logger.LogTrace(JsonConvert.SerializeObject(value: request));

            try
            {
                var response = await this.Repository.PurgeQueueAsync(request : request,
                                                                     cancellationToken : cancellationToken == default?this.CancellationToken.Token : cancellationToken);

                this.Logger.LogTrace(JsonConvert.SerializeObject(value: response));

                return(response);
            }
            catch (Amazon.SQS.Model.PurgeQueueInProgressException ex)
            {
                this.Logger.LogError(ex.Message);

                return(null);
            }
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SQS.Model.PurgeQueueRequest();

            if (cmdletContext.QueueUrl != null)
            {
                request.QueueUrl = cmdletContext.QueueUrl;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
 private Amazon.SQS.Model.PurgeQueueResponse CallAWSServiceOperation(IAmazonSQS client, Amazon.SQS.Model.PurgeQueueRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Queue Service (SQS)", "PurgeQueue");
     try
     {
         #if DESKTOP
         return(client.PurgeQueue(request));
         #elif CORECLR
         return(client.PurgeQueueAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Пример #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the PurgeQueue operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PurgeQueue operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<PurgeQueueResponse> PurgeQueueAsync(PurgeQueueRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PurgeQueueRequestMarshaller();
            var unmarshaller = PurgeQueueResponseUnmarshaller.Instance;

            return InvokeAsync<PurgeQueueRequest,PurgeQueueResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Пример #5
0
 /// <summary>
 /// Deletes the messages in a queue specified by the <code>QueueURL</code> parameter.
 /// 
 ///  <important> 
 /// <para>
 /// When you use the <code>PurgeQueue</code> action, you can't retrieve a message deleted
 /// from a queue.
 /// </para>
 ///  </important> 
 /// <para>
 /// When you purge a queue, the message deletion process takes up to 60 seconds. All messages
 /// sent to the queue before calling the <code>PurgeQueue</code> action are deleted. Messages
 /// sent to the queue while it is being purged might be deleted. While the queue is being
 /// purged, messages sent to the queue before <code>PurgeQueue</code> is called might
 /// be received, but are deleted within the next minute.
 /// </para>
 /// </summary>
 /// <param name="queueUrl">The URL of the queue from which the <code>PurgeQueue</code> action deletes messages. Queue URLs are case-sensitive.</param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the PurgeQueue service method, as returned by SQS.</returns>
 /// <exception cref="Amazon.SQS.Model.PurgeQueueInProgressException">
 /// Indicates that the specified queue previously received a <code>PurgeQueue</code> request
 /// within the last 60 seconds (the time it can take to delete the messages in the queue).
 /// </exception>
 /// <exception cref="Amazon.SQS.Model.QueueDoesNotExistException">
 /// The queue referred to doesn't exist.
 /// </exception>
 public Task<PurgeQueueResponse> PurgeQueueAsync(string queueUrl, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new PurgeQueueRequest();
     request.QueueUrl = queueUrl;
     return PurgeQueueAsync(request, cancellationToken);
 }
Пример #6
0
        /// <summary>
        /// Deletes the messages in a queue specified by the <code>QueueURL</code> parameter.
        /// 
        ///  <important> 
        /// <para>
        /// When you use the <code>PurgeQueue</code> action, you can't retrieve a message deleted
        /// from a queue.
        /// </para>
        ///  </important> 
        /// <para>
        /// When you purge a queue, the message deletion process takes up to 60 seconds. All messages
        /// sent to the queue before calling the <code>PurgeQueue</code> action are deleted. Messages
        /// sent to the queue while it is being purged might be deleted. While the queue is being
        /// purged, messages sent to the queue before <code>PurgeQueue</code> is called might
        /// be received, but are deleted within the next minute.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the PurgeQueue service method.</param>
        /// 
        /// <returns>The response from the PurgeQueue service method, as returned by SQS.</returns>
        /// <exception cref="Amazon.SQS.Model.PurgeQueueInProgressException">
        /// Indicates that the specified queue previously received a <code>PurgeQueue</code> request
        /// within the last 60 seconds (the time it can take to delete the messages in the queue).
        /// </exception>
        /// <exception cref="Amazon.SQS.Model.QueueDoesNotExistException">
        /// The queue referred to doesn't exist.
        /// </exception>
        public PurgeQueueResponse PurgeQueue(PurgeQueueRequest request)
        {
            var marshaller = new PurgeQueueRequestMarshaller();
            var unmarshaller = PurgeQueueResponseUnmarshaller.Instance;

            return Invoke<PurgeQueueRequest,PurgeQueueResponse>(request, marshaller, unmarshaller);
        }
Пример #7
0
 /// <summary>
 /// Deletes the messages in a queue specified by the <code>QueueURL</code> parameter.
 /// 
 ///  <important> 
 /// <para>
 /// When you use the <code>PurgeQueue</code> action, you can't retrieve a message deleted
 /// from a queue.
 /// </para>
 ///  </important> 
 /// <para>
 /// When you purge a queue, the message deletion process takes up to 60 seconds. All messages
 /// sent to the queue before calling the <code>PurgeQueue</code> action are deleted. Messages
 /// sent to the queue while it is being purged might be deleted. While the queue is being
 /// purged, messages sent to the queue before <code>PurgeQueue</code> is called might
 /// be received, but are deleted within the next minute.
 /// </para>
 /// </summary>
 /// <param name="queueUrl">The URL of the queue from which the <code>PurgeQueue</code> action deletes messages. Queue URLs are case-sensitive.</param>
 /// 
 /// <returns>The response from the PurgeQueue service method, as returned by SQS.</returns>
 /// <exception cref="Amazon.SQS.Model.PurgeQueueInProgressException">
 /// Indicates that the specified queue previously received a <code>PurgeQueue</code> request
 /// within the last 60 seconds (the time it can take to delete the messages in the queue).
 /// </exception>
 /// <exception cref="Amazon.SQS.Model.QueueDoesNotExistException">
 /// The queue referred to doesn't exist.
 /// </exception>
 public PurgeQueueResponse PurgeQueue(string queueUrl)
 {
     var request = new PurgeQueueRequest();
     request.QueueUrl = queueUrl;
     return PurgeQueue(request);
 }
Пример #8
0
        /// <summary>
        /// Initiates the asynchronous execution of the PurgeQueue operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PurgeQueue operation on AmazonSQSClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPurgeQueue
        ///         operation.</returns>
        public IAsyncResult BeginPurgeQueue(PurgeQueueRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new PurgeQueueRequestMarshaller();
            var unmarshaller = PurgeQueueResponseUnmarshaller.Instance;

            return BeginInvoke<PurgeQueueRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Пример #9
0
 public Task<PurgeQueueResponse> PurgeQueueAsync(PurgeQueueRequest request, CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }
Пример #10
0
 public PurgeQueueResponse PurgeQueue(PurgeQueueRequest request)
 {
     var q = GetQueue(request.QueueUrl);
     q.Clear();
     return new PurgeQueueResponse();
 }
Пример #11
0
 /// <summary>
 /// Initiates the asynchronous execution of the PurgeQueue operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the PurgeQueue operation on AmazonSQSClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void PurgeQueueAsync(PurgeQueueRequest request, AmazonServiceCallback<PurgeQueueRequest, PurgeQueueResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new PurgeQueueRequestMarshaller();
     var unmarshaller = PurgeQueueResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<PurgeQueueRequest,PurgeQueueResponse> responseObject 
                     = new AmazonServiceResult<PurgeQueueRequest,PurgeQueueResponse>((PurgeQueueRequest)req, (PurgeQueueResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<PurgeQueueRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
Пример #12
0
 /// <summary>
 /// Deletes the messages in a queue specified by the <b>queue URL</b>.
 /// 
 ///  <important>When you use the <code>PurgeQueue</code> API, the deleted messages in
 /// the queue cannot be retrieved.</important> 
 /// <para>
 /// When you purge a queue, the message deletion process takes up to 60 seconds. All messages
 /// sent to the queue before calling <code>PurgeQueue</code> will be deleted; messages
 /// sent to the queue while it is being purged may be deleted. While the queue is being
 /// purged, messages sent to the queue before <code>PurgeQueue</code> was called may be
 /// received, but will be deleted within the next minute.
 /// </para>
 /// </summary>
 /// <param name="queueUrl">The queue URL of the queue to delete the messages from when using the <code>PurgeQueue</code> API.</param>
 /// <param name="options">
  ///     A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
  ///     procedure using the AsyncState property.
  /// </param>
 /// 
 /// <returns>The response from the PurgeQueue service method, as returned by SQS.</returns>
 /// <exception cref="Amazon.SQS.Model.PurgeQueueInProgressException">
 /// Indicates that the specified queue previously received a <code>PurgeQueue</code> request
 /// within the last 60 seconds, the time it can take to delete the messages in the queue.
 /// </exception>
 /// <exception cref="Amazon.SQS.Model.QueueDoesNotExistException">
 /// The queue referred to does not exist.
 /// </exception>
 public void PurgeQueueAsync(string queueUrl,  AmazonServiceCallback<PurgeQueueRequest, PurgeQueueResponse> callback, AsyncOptions options = null)
 {
     var request = new PurgeQueueRequest();
     request.QueueUrl = queueUrl;
     PurgeQueueAsync(request, callback, options);
 }
Пример #13
0
        public static void PurgeQueueByQueueUrl(string queueUrl)
        {
            using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
            {
                var request = new PurgeQueueRequest()
                {
                    QueueUrl = queueUrl
                };

                client.PurgeQueue(request);
            }
        }