Container for the parameters to the DeleteMessage operation. Deletes the specified message from the specified queue. You specify the message by using the message's receipt handle and not the MessageId you receive when you send the message. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue. If you leave a message in the queue for longer than the queue's configured retention period, Amazon SQS automatically deletes the message.

The receipt handle is associated with a specific instance of receiving the message. If you receive a message more than once, the receipt handle you get each time you receive the message is different. If you don't provide the most recently received receipt handle for the message when you use the DeleteMessage action, the request succeeds, but the message might not be deleted.

For standard queues, it is possible to receive a message even after you deleting it. This might happen on rare occasions if one of the servers storing a copy of the message is unavailable when you send the request to delete the message. The copy remains on the server and might be returned to you on a subsequent receive request. You should ensure that your application is idempotent, so that receiving a message more than once does not cause issues.

Inheritance: AmazonSQSRequest
コード例 #1
0
        private void ReceiveMessage()
        {
            var receiveMessageRequest = new ReceiveMessageRequest();
            receiveMessageRequest.QueueUrl = _handler.QueueUrl;
            var receiveMessageResponse = _sqsClient.ReceiveMessage(receiveMessageRequest);
            if (receiveMessageResponse.IsSetReceiveMessageResult() && receiveMessageResponse.ReceiveMessageResult.Message.Count > 0)
            {
                Console.WriteLine("Received message");
                var receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
                foreach (Message message in receiveMessageResult.Message)
                {
                    Console.WriteLine("Message body: {0}", message.Body);
                    foreach (var handler in Container.GetAll<IServiceHandler>())
                    {
                        //TODO - need to refactor this, multiple handlers means multiple deserialization
                        if (handler.QueueName == _handler.QueueName && handler.IsRequestHandled(message))
                        {
                            Console.WriteLine("Passing request to handler: {0}", handler.GetType().Name);
                            handler.HandleRequest(message);
                        }
                    }
                }

                Console.WriteLine("Deleting message");
                var messageRecieptHandle = receiveMessageResponse.ReceiveMessageResult.Message[0].ReceiptHandle;
                var deleteRequest = new DeleteMessageRequest()
                                            .WithQueueUrl(_handler.QueueUrl)
                                            .WithReceiptHandle(messageRecieptHandle);
                _sqsClient.DeleteMessage(deleteRequest);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sbulluk/BlogSample-AWS-SQS
 private static void DeleteMessageFromQueue(string receiptHandle)
 {
     var request = new DeleteMessageRequest(
         queueUrl: _awsConfig.QueueUrl,
         receiptHandle: receiptHandle);
     var response = _client.DeleteMessage(request);
 }
コード例 #3
0
        public async Task <DeleteMessageResponse> DeleteMessageAsync(string queueUrl,
                                                                     string receiptHandle,
                                                                     CancellationToken cancellationToken = default)
        {
            this.Logger.LogDebug($"[{nameof(this.DeleteMessageAsync)}]");

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

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

            var request = new Amazon.SQS.Model.DeleteMessageRequest
            {
                QueueUrl      = queueUrl,
                ReceiptHandle = receiptHandle,
            };

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

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

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

            return(response);
        }
コード例 #4
0
ファイル: SQS.cs プロジェクト: tamirez3dco/Rendering_Code
        public static bool Delete_Msg_From_Req_Q(Amazon.SQS.Model.Message msg)
        {
            try
            {
                String messageRecieptHandle = msg.ReceiptHandle;

                //Deleting a message
                Console.WriteLine("Deleting the message.\n");
                DeleteMessageRequest deleteRequest = new DeleteMessageRequest();
                deleteRequest.QueueUrl = requests_Q_url;
                deleteRequest.ReceiptHandle = messageRecieptHandle;
                Console.WriteLine("Before deleting incoming msg(" + messageRecieptHandle + ").");
                sqs.DeleteMessage(deleteRequest);
                Console.WriteLine("After deleting incoming msgs().");

            }
            catch (AmazonSQSException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
                return false;
            }
            return true;
        }
コード例 #5
0
        public async Task <IList <Loan> > GetFromQueue()
        {
            ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();

            receiveMessageRequest.QueueUrl            = _queueURL;
            receiveMessageRequest.MaxNumberOfMessages = 10;
            var result = await _amazonSQSClient.ReceiveMessageAsync(receiveMessageRequest);

            var loanList = new List <Loan>();

            foreach (var item in result.Messages)
            {
                try
                {
                    Amazon.SQS.Model.DeleteMessageRequest deleteReq = new Amazon.SQS.Model.DeleteMessageRequest();
                    deleteReq.QueueUrl      = _queueURL;
                    deleteReq.ReceiptHandle = item.ReceiptHandle;
                    var deleteResp = await _amazonSQSClient.DeleteMessageAsync(deleteReq);
                }
                catch (Exception ex)
                {
                    _logger.LogError("Error: {Message}", ex.ToString());
                }
                var loan = JsonSerializer.Deserialize <Loan>(item.Body);
                loanList.Add(loan);
            }
            return(loanList);
        }
コード例 #6
0
        /// <summary>
        /// The DeleteMessage action unconditionally removes the specified message from the specified queue. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonSQS service</param>
        /// <param name="request">DeleteMessageRequest request</param>
        public static void InvokeDeleteMessage(AmazonSQS service, DeleteMessageRequest request)
        {
            try 
            {
                DeleteMessageResponse response = service.DeleteMessage(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        DeleteMessageResponse");
                if (response.IsSetResponseMetadata()) 
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId()) 
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                } 

            } 
            catch (AmazonSQSException ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
コード例 #7
0
ファイル: SQSOperations.cs プロジェクト: ralfw/appzwitschern
 private void Delete_message(string receiptHandle)
 {
     var deleteRequest = new DeleteMessageRequest {
         QueueUrl = _queueUrl,
         ReceiptHandle = receiptHandle
     };
     _sqs.DeleteMessage(deleteRequest);
 }
コード例 #8
0
 public static string Delete(string queue_url, string msg_id)
 {
     AmazonSQS sqs = AWSClientFactory.CreateAmazonSQSClient();
     DeleteMessageRequest d_msgreq = new DeleteMessageRequest();
     d_msgreq.QueueUrl = queue_url;
     d_msgreq.ReceiptHandle = msg_id;
     DeleteMessageResponse d_msgres = sqs.DeleteMessage(d_msgreq);
     return "Deleted Message \n" + d_msgres.ResponseMetadata.ToString();
 }
コード例 #9
0
        public void DeleteMessage(IQueue queue, IQueueMessage message)
        {
            var awsMessage = (AwsQueueMessage)message;

            DeleteMessageRequest request = new DeleteMessageRequest()
                .WithQueueUrl(queue.Id)
                .WithReceiptHandle(awsMessage.ReceiptHandle);
            _sqsClient.DeleteMessage(request);
        }
コード例 #10
0
ファイル: QueueAdmin.cs プロジェクト: RPM1984/amazonsqs
        public void DeleteMessage(string queueUrl, string receiptHandle)
        {
            var req = new DeleteMessageRequest() {
                QueueUrl = queueUrl,
                ReceiptHandle = receiptHandle
            };

            client.DeleteMessage(req);
        }
コード例 #11
0
    /// <summary>
    /// Constant SQS Message Polling Coroutine, process message, and then maybe delete the message
    /// </summary>
    /// <param name="waitTime"></param>
    /// <returns></returns>
    IEnumerator RepeatRetrieveMessage(float waitTime)
    {
        bool checkSQS = true;

        while (checkSQS)
        {
            yield return(new WaitForSeconds(waitTime));

            if (!string.IsNullOrEmpty(queueUrl))
            {
                SqsClient.ReceiveMessageAsync(queueUrl, (result) =>
                {
                    if (result.Exception == null)
                    {
                        //Read the message
                        var messages = result.Response.Messages;
                        messages.ForEach(m =>
                        {
                            Debug.Log(@"Message Id  = " + m.MessageId);
                            Debug.Log(@"Mesage = " + m.Body);

                            //Process the message
                            //[do your thing here]

                            //Delete the message
                            var delRequest = new Amazon.SQS.Model.DeleteMessageRequest
                            {
                                QueueUrl      = queueUrl,
                                ReceiptHandle = m.ReceiptHandle
                            };

                            SqsClient.DeleteMessageAsync(delRequest, (delResult) =>
                            {
                                if (delResult.Exception == null)
                                {
                                }
                                else
                                {
                                }
                            });
                        });
                    }
                    else
                    {
                        Debug.LogException(result.Exception);
                    }
                });
            }
            else
            {
                Debug.Log(@"Queue Url is empty, make sure that the queue is created first");
            }

            //Debug.Log (".");
        }
    }
コード例 #12
0
        public bool DeleteMessage(DeleteMessageRequest request)
        {   // Handle still has to be valid
            if (request.ReceiptHandle.Equals(FakeBatchItemFailString, StringComparison.InvariantCultureIgnoreCase))
            {
                return false;
            }

            var item = GetInFlightItem(request.ReceiptHandle);
            return inFlighItems.TryRemove(request.ReceiptHandle, out item);
        }
コード例 #13
0
        public bool Delete(DeleteMessageRequest request)
        {
            if (request == null)
            {
                return false;
            }

            var response = SqsClient.DeleteMessage(request);
            return response != null;
        }
コード例 #14
0
    IEnumerator RepeatRetrieveMessage(float waitTime)
    {
        bool checkSQS = true;

        while (checkSQS)
        {
            yield return(new WaitForSeconds(waitTime));

            if (!string.IsNullOrEmpty(queueUrl))
            {
                SqsClient.ReceiveMessageAsync(queueUrl, (result) => {
                    if (result.Exception == null)
                    {
                        //Read the message
                        var messages = result.Response.Messages;
                        messages.ForEach(m => {
                            RemoteCommand command = RemoteCommand.CreateFromJSON(m.Body);
                            Debug.Log(@"Target " + command.target);
                            int index = Int32.Parse(command.target);
                            activateCam(index);
                            Debug.Log(@"Done switching camera");

                            //Delete the message
                            var delRequest = new Amazon.SQS.Model.DeleteMessageRequest {
                                QueueUrl      = queueUrl,
                                ReceiptHandle = m.ReceiptHandle
                            };

                            SqsClient.DeleteMessageAsync(delRequest, (delResult) => {
                                if (delResult.Exception == null)
                                {
                                }
                                else
                                {
                                }
                            });


                            Debug.Log(@"Done processing message ");
                        });
                    }
                    else
                    {
                        Debug.Log(result.Exception);
                        Debug.LogException(result.Exception);
                    }
                });
            }
            else
            {
                Debug.Log(@"Queue Url is empty, make sure that the queue is created first");
            }
        }
    }
コード例 #15
0
        protected override bool Execute(AmazonSQS client)
        {
            Logger.LogMessage(MessageImportance.Normal, "Deleting message {0} from Queue {1}", ReceiptHandle, QueueUrl);

            var request = new DeleteMessageRequest { QueueUrl = QueueUrl, ReceiptHandle = ReceiptHandle };
            client.DeleteMessage(request);

            Logger.LogMessage(MessageImportance.Normal, "Deleted message {0} from queue {1}", ReceiptHandle, QueueUrl);

            return true;
        }
コード例 #16
0
        public string DeleteMessage(Uri queueUrl, string receiptHandle)
        {
            queueUrl.Requires("queueUrl").IsNotNull();
            receiptHandle.Requires("receiptHandle").IsNotNullOrWhiteSpace();

            var deleteMessageRequest = new DeleteMessageRequest(queueUrl.AbsoluteUri, receiptHandle);
            using (var sqs = amazonSqsFactory())
            {
                var deleteResponseMessage = sqs.DeleteMessage(deleteMessageRequest);
                return deleteResponseMessage.ResponseMetadata.RequestId;
            }
        }
コード例 #17
0
        public string DeleteMessage(Uri queueUrl, string receiptHandle)
        {
            Validate.That(queueUrl).IsNotNull();
            Validate.That(receiptHandle).IsNotNullOrEmpty();

            var deleteMessageRequest =
                new DeleteMessageRequest().WithQueueUrl(queueUrl.AbsoluteUri).WithReceiptHandle(receiptHandle);
            using (var sqs = amazonSqsFactory())
            {
                var deleteResponseMessage = sqs.DeleteMessage(deleteMessageRequest);
                return deleteResponseMessage.ResponseMetadata.RequestId;
            }
        }
 /// <summary>
 /// Instantiates the Poller.
 /// </summary>
 /// <param name="props">
 /// A <see cref="MessageGearsProperties"/>
 /// </param>
 /// <param name="listener">
 /// A <see cref="MessageGearsListener"/>
 /// </param>
 /// <param name="myAwsAccountKey">
 /// You AWS Account Key
 /// </param>
 /// <param name="myAwsSecretKey">
 /// Your AWS Secret Key
 /// </param>
 public MessageGearsAwsQueuePoller(MessageGearsAwsProperties props, MessageGearsListener listener)
 {
     this.props = props;
     this.emptyQueueDelayMillis = props.EmptyQueuePollingDelaySecs * 1000;
     this.listener = listener;
     AmazonSQSConfig config = new AmazonSQSConfig().WithMaxErrorRetry(props.SQSMaxErrorRetry);
     this.sqs = AWSClientFactory.CreateAmazonSQSClient (props.MyAWSAccountKey, props.MyAWSSecretKey, config);
     this.receiveMessageRequest = new ReceiveMessageRequest ()
         .WithQueueUrl (props.MyAWSEventQueueUrl)
         .WithMaxNumberOfMessages (props.SQSMaxBatchSize)
         .WithAttributeName("ApproximateReceiveCount")
         .WithVisibilityTimeout(props.SQSVisibilityTimeoutSecs);
     this.deleteMessageRequest = new DeleteMessageRequest().WithQueueUrl(props.MyAWSEventQueueUrl);
 }
コード例 #19
0
        static void Main(string[] args)
        {
            // AWS: Get instance public address
            string myId = "localhost";
            try
            {
                myId = Encoding.ASCII.GetString(new WebClient().DownloadData("http://169.254.169.254/latest/meta-data/public-hostname"));
            }
            catch
            {
            }

            // AWS SQS Client
            var sqsClient = new AmazonSQSClient();

            while (true)
            {
                // Get the next message
                ReceiveMessageRequest request = new ReceiveMessageRequest()
                    .WithQueueUrl("https://queue.amazonaws.com/*****/codeCampDemo")
                    .WithMaxNumberOfMessages(1);
                var response = sqsClient.ReceiveMessage(request);

                foreach (var retrievedMessage in response.ReceiveMessageResult.Message)
                {
                    var messageJson = JsonValue.Parse(retrievedMessage.Body);

                    var message = messageJson["message"].ReadAs<string>();

                    Console.WriteLine(message);

                    message = "Echo: " + message;

                    string address = string.Format("http://{0}", messageJson["sender"].ReadAs<string>());
                    var connection = new HubConnection(address);
                    connection.Start().Wait();

                    IHubProxy pongHub = connection.CreateProxy("MvcWebRole1.Hubs.EchoHub");
                    pongHub.Invoke("DoUpdateMessage", message, myId).Wait();

                    //Process the message and then delete the message
                    DeleteMessageRequest deleteRequest = new DeleteMessageRequest()
                        .WithQueueUrl("https://queue.amazonaws.com/******/codeCampDemo")
                        .WithReceiptHandle(retrievedMessage.ReceiptHandle);
                    sqsClient.DeleteMessage(deleteRequest);
                }

                Thread.Sleep(1000);
            }
        }
コード例 #20
0
ファイル: MessageQueue.cs プロジェクト: trevorpower/tadmap
      public void Remove(IMessage message)
      {
         try
         {
            if (message is AmazonMessage)
            {
               DeleteMessageRequest deleteRequest = new DeleteMessageRequest()
               {
                  QueueName = Name,
                  ReceiptHandle = (message as AmazonMessage).Message.ReceiptHandle
               };

               _client.DeleteMessage(deleteRequest);
            }
         }
         catch (AmazonSQSException e)
         {
            throw new MessageQueueException(string.Format("Failed to remove message from '{0}'.", Name), e);
         }
      }
コード例 #21
0
ファイル: Form1.cs プロジェクト: HappiestTeam/Spikes
        private void button2_Click(object sender, EventArgs e)
        {
            ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
            receiveMessageRequest.QueueUrl = myQueueUrl;
            ReceiveMessageResponse receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);
            if (receiveMessageResponse.IsSetReceiveMessageResult())
            {
                ReceiveMessageResult receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
                foreach (Amazon.SQS.Model.Message message in receiveMessageResult.Message)
                {
                    if (message.IsSetBody())
                     MessageBox.Show(message.Body);
                }
            }

            String messageRecieptHandle = receiveMessageResponse.ReceiveMessageResult.Message[0].ReceiptHandle;
            DeleteMessageRequest deleteRequest = new DeleteMessageRequest();
            deleteRequest.QueueUrl = myQueueUrl;
            deleteRequest.ReceiptHandle = messageRecieptHandle;
            sqs.DeleteMessage(deleteRequest);
        }
コード例 #22
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SQS.Model.DeleteMessageRequest();

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

            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);
        }
コード例 #23
0
        public static string DequeueByQueueUrl(string queueUrl)
        {
            using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
            {
                var request = new ReceiveMessageRequest()
                {
                    QueueUrl = queueUrl
                };

                var response = client.ReceiveMessage(request).Messages.First();

                var body = response.Body;

                var deleteRequest = new DeleteMessageRequest
                {
                    QueueUrl = queueUrl,
                    ReceiptHandle = response.ReceiptHandle
                };

                client.DeleteMessage(deleteRequest);

                return body;
            }
        }
コード例 #24
0
		internal DeleteMessageResponse DeleteMessage(DeleteMessageRequest request)
        {
            var task = DeleteMessageAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
コード例 #25
0
        /// <summary>
        /// <para>The <c>DeleteMessage</c> action unconditionally removes the specified message from the specified queue. Even if the message is locked
        /// by another reader due to the visibility timeout setting, it is still deleted from the queue.</para>
        /// </summary>
        /// 
        /// <param name="deleteMessageRequest">Container for the necessary parameters to execute the DeleteMessage service method on AmazonSQS.</param>
        /// 
        /// <exception cref="T:Amazon.SQS.Model.ReceiptHandleIsInvalidException" />
        /// <exception cref="T:Amazon.SQS.Model.InvalidIdFormatException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<DeleteMessageResponse> DeleteMessageAsync(DeleteMessageRequest deleteMessageRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteMessageRequestMarshaller();
            var unmarshaller = DeleteMessageResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, DeleteMessageRequest, DeleteMessageResponse>(deleteMessageRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
コード例 #26
0
        private void ReceiveMessage()
        {
            var receiveMessageRequest = new ReceiveMessageRequest();
            receiveMessageRequest.QueueUrl = _queueUrl;
            var receiveMessageResponse = _sqsClient.ReceiveMessage(receiveMessageRequest);
            if (receiveMessageResponse.IsSetReceiveMessageResult() && receiveMessageResponse.ReceiveMessageResult.Message.Count > 0)
            {
                Console.WriteLine("Received message at: {0}", DateTime.Now.ToLongTimeString());
                var receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
                foreach (Message message in receiveMessageResult.Message)
                {
                    Console.WriteLine("Message body: {0}", message.Body);
                }

                var response = receiveMessageResponse.FirstMessageAsResponse<QueryServiceResponse>();
                if (response != null)
                {
                    //fetch the data from the response store:
                    Console.WriteLine("Fetching data at: {0}", DateTime.Now.ToLongTimeString());
                    var responseItems = DataStore.Current.Fetch(response.StoreIdentifier, response.ItemKey);
                    var employees = new List<Employee>(responseItems.Count());
                    foreach (var responseItem in responseItems)
                    {
                        var employee = Serializer.Current.Deserialize(typeof(Employee), responseItem) as Employee;
                        Console.WriteLine("Adding employee - {0}", employee);
                        employees.Add(employee);
                    }
                }

                Console.WriteLine("Deleting message");
                var messageRecieptHandle = receiveMessageResponse.ReceiveMessageResult.Message[0].ReceiptHandle;
                var deleteRequest = new DeleteMessageRequest()
                                            .WithQueueUrl(_queueUrl)
                                            .WithReceiptHandle(messageRecieptHandle);
                _sqsClient.DeleteMessage(deleteRequest);
                Console.WriteLine("Completed at: {0}", DateTime.Now.ToLongTimeString());
            }
        }
コード例 #27
0
        /// <summary>
        /// <para> Deletes the specified message from the specified queue. You specify the message by using the message's <c>receipt handle</c> and not
        /// the <c>message ID</c> you received when you sent the message. Even if the message is locked by another reader due to the visibility timeout
        /// setting, it is still deleted from the queue. If you leave a message in the queue for longer than the queue's configured retention period,
        /// Amazon SQS automatically deletes it. </para> <para><b>NOTE:</b> The receipt handle is associated with a specific instance of receiving the
        /// message. If you receive a message more than once, the receipt handle you get each time you receive the message is different. When you
        /// request DeleteMessage, if you don't provide the most recently received receipt handle for the message, the request will still succeed, but
        /// the message might not be deleted. </para> <para><b>IMPORTANT:</b> It is possible you will receive a message even after you have deleted it.
        /// This might happen on rare occasions if one of the servers storing a copy of the message is unavailable when you request to delete the
        /// message. The copy remains on the server and might be returned to you again on a subsequent receive request. You should create your system to
        /// be idempotent so that receiving a particular message more than once is not a problem. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteMessage service method on AmazonSQS.</param>
        /// 
        /// <exception cref="T:Amazon.SQS.Model.ReceiptHandleIsInvalidException" />
        /// <exception cref="T:Amazon.SQS.Model.InvalidIdFormatException" />
		public DeleteMessageResponse DeleteMessage(DeleteMessageRequest request)
        {
            var task = DeleteMessageAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
コード例 #28
0
 IAsyncResult invokeDeleteMessage(DeleteMessageRequest deleteMessageRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DeleteMessageRequestMarshaller().Marshall(deleteMessageRequest);
     var unmarshaller = DeleteMessageResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
コード例 #29
0
 private Amazon.SQS.Model.DeleteMessageResponse CallAWSServiceOperation(IAmazonSQS client, Amazon.SQS.Model.DeleteMessageRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Queue Service (SQS)", "DeleteMessage");
     try
     {
         #if DESKTOP
         return(client.DeleteMessage(request));
         #elif CORECLR
         return(client.DeleteMessageAsync(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;
     }
 }
コード例 #30
0
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteMessage operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS.DeleteMessage"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteMessage 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 async Task<DeleteMessageResponse> DeleteMessageAsync(DeleteMessageRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteMessageRequestMarshaller();
            var unmarshaller = DeleteMessageResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, DeleteMessageRequest, DeleteMessageResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
コード例 #31
0
 public virtual void RemoveMessage(AmazonSQSClient sqsClient, string queueUrl, string receiptHandle)
 {
     // Create the request
     var deleteMessageRequest = new DeleteMessageRequest
     {
         ReceiptHandle = receiptHandle,
         QueueUrl = queueUrl
     };
     // Submit the request
     sqsClient.DeleteMessage(deleteMessageRequest);
 }
コード例 #32
0
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteMessage operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteMessage 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 EndDeleteMessage
        ///         operation.</returns>
        public IAsyncResult BeginDeleteMessage(DeleteMessageRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DeleteMessageRequestMarshaller();
            var unmarshaller = DeleteMessageResponseUnmarshaller.Instance;

            return BeginInvoke<DeleteMessageRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
コード例 #33
0
        /// <summary>
        /// Deletes the specified message from the specified      queue. You specify the
        /// message by using the message's <code>receipt        handle</code> and not the <code>message
        /// ID</code> you received when you      sent the message. Even if the message is locked
        /// by another reader due to the visibility      timeout setting, it is still deleted
        /// from the queue. If you leave a message in the queue      for longer than the queue's
        /// configured retention period, Amazon SQS automatically deletes      it.        
        /// 
        ///     <note>      
        /// <para>
        ///         The receipt handle is associated with a specific instance of receiving the
        /// message. If        you receive a message more than once, the receipt handle you get
        /// each time you receive the        message is different. When you request <code>DeleteMessage</code>,
        /// if you don't        provide the most recently received receipt handle for the message,
        /// the request will still        succeed, but the message might not be deleted.     
        /// 
        /// </para>
        ///     </note>    <important>    
        /// <para>
        ///       It is possible you will receive a message even after you have deleted it. This
        /// might      happen on rare occasions if one of the servers storing a copy of the message
        /// is unavailable      when you request to delete the message. The copy remains on the
        /// server and might be returned      to you again on a subsequent receive request. You
        /// should create your system to be idempotent      so that receiving a particular message
        /// more than once is not a problem.    
        /// </para>
        ///     </important>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the DeleteMessage service method.</param>
        /// 
        /// <returns>The response from the DeleteMessage service method, as returned by SQS.</returns>
        /// <exception cref="InvalidIdFormatException">
        /// The receipt handle is not valid for the current version.
        /// </exception>
        /// <exception cref="ReceiptHandleIsInvalidException">
        /// The receipt handle provided is not valid.
        /// </exception>
        public DeleteMessageResponse DeleteMessage(DeleteMessageRequest request)
        {
            var marshaller = new DeleteMessageRequestMarshaller();
            var unmarshaller = DeleteMessageResponseUnmarshaller.Instance;

            return Invoke<DeleteMessageRequest,DeleteMessageResponse>(request, marshaller, unmarshaller);
        }
コード例 #34
0
 /// <summary>
 /// Deletes the specified message from the specified      queue. You specify the
 /// message by using the message's <code>receipt        handle</code> and not the <code>message
 /// ID</code> you received when you      sent the message. Even if the message is locked
 /// by another reader due to the visibility      timeout setting, it is still deleted
 /// from the queue. If you leave a message in the queue      for longer than the queue's
 /// configured retention period, Amazon SQS automatically deletes      it.        
 /// 
 ///     <note>      
 /// <para>
 ///         The receipt handle is associated with a specific instance of receiving the
 /// message. If        you receive a message more than once, the receipt handle you get
 /// each time you receive the        message is different. When you request <code>DeleteMessage</code>,
 /// if you don't        provide the most recently received receipt handle for the message,
 /// the request will still        succeed, but the message might not be deleted.     
 /// 
 /// </para>
 ///     </note>    <important>    
 /// <para>
 ///       It is possible you will receive a message even after you have deleted it. This
 /// might      happen on rare occasions if one of the servers storing a copy of the message
 /// is unavailable      when you request to delete the message. The copy remains on the
 /// server and might be returned      to you again on a subsequent receive request. You
 /// should create your system to be idempotent      so that receiving a particular message
 /// more than once is not a problem.    
 /// </para>
 ///     </important>
 /// </summary>
 /// <param name="queueUrl">The URL of the Amazon SQS queue to take action on.</param>
 /// <param name="receiptHandle">The receipt handle associated with the message to delete.</param>
 /// 
 /// <returns>The response from the DeleteMessage service method, as returned by SQS.</returns>
 /// <exception cref="InvalidIdFormatException">
 /// The receipt handle is not valid for the current version.
 /// </exception>
 /// <exception cref="ReceiptHandleIsInvalidException">
 /// The receipt handle provided is not valid.
 /// </exception>
 public DeleteMessageResponse DeleteMessage(string queueUrl, string receiptHandle)
 {
     var request = new DeleteMessageRequest();
     request.QueueUrl = queueUrl;
     request.ReceiptHandle = receiptHandle;
     return DeleteMessage(request);
 }
コード例 #35
0
ファイル: AmazonSQSClient.cs プロジェクト: aws/aws-sdk-net
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteMessage operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteMessage 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<DeleteMessageResponse> DeleteMessageAsync(DeleteMessageRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteMessageRequestMarshaller();
            var unmarshaller = DeleteMessageResponseUnmarshaller.Instance;

            return InvokeAsync<DeleteMessageRequest,DeleteMessageResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
コード例 #36
0
ファイル: AmazonSQSClient.cs プロジェクト: aws/aws-sdk-net
 /// <summary>
 /// Deletes the specified message from the specified queue. You specify the message by
 /// using the message's <i>receipt handle</i> and not the <i>MessageId</i> you receive
 /// when you send the message. Even if the message is locked by another reader due to
 /// the visibility timeout setting, it is still deleted from the queue. If you leave a
 /// message in the queue for longer than the queue's configured retention period, Amazon
 /// SQS automatically deletes the message. 
 /// 
 ///  <note> 
 /// <para>
 ///  The receipt handle is associated with a specific instance of receiving the message.
 /// If you receive a message more than once, the receipt handle you get each time you
 /// receive the message is different. If you don't provide the most recently received
 /// receipt handle for the message when you use the <code>DeleteMessage</code> action,
 /// the request succeeds, but the message might not be deleted.
 /// </para>
 ///  
 /// <para>
 /// For standard queues, it is possible to receive a message even after you deleting it.
 /// This might happen on rare occasions if one of the servers storing a copy of the message
 /// is unavailable when you send the request to delete the message. The copy remains on
 /// the server and might be returned to you on a subsequent receive request. You should
 /// ensure that your application is idempotent, so that receiving a message more than
 /// once does not cause issues.
 /// </para>
 ///  </note>
 /// </summary>
 /// <param name="queueUrl">The URL of the Amazon SQS queue from which messages are deleted. Queue URLs are case-sensitive.</param>
 /// <param name="receiptHandle">The receipt handle associated with the message to delete.</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 DeleteMessage service method, as returned by SQS.</returns>
 /// <exception cref="Amazon.SQS.Model.InvalidIdFormatException">
 /// The receipt handle isn't valid for the current version.
 /// </exception>
 /// <exception cref="Amazon.SQS.Model.ReceiptHandleIsInvalidException">
 /// The receipt handle provided isn't valid.
 /// </exception>
 public Task<DeleteMessageResponse> DeleteMessageAsync(string queueUrl, string receiptHandle, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new DeleteMessageRequest();
     request.QueueUrl = queueUrl;
     request.ReceiptHandle = receiptHandle;
     return DeleteMessageAsync(request, cancellationToken);
 }