public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { SetQueueAttributesResponse response = new SetQueueAttributesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("SetQueueAttributesResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
public override WebServiceResponse Unmarshall(XmlUnmarshallerContext context) { SetQueueAttributesResponse response = new SetQueueAttributesResponse(); // Nothing need to do with this response here return(response); }
private void SetQueueVisibilityTimeoutAttribute(int visibilityTimeOutInMinutes) { Dictionary <string, string> queueAttributes = new Dictionary <string, string>(); queueAttributes.Add("VisibilityTimeout", (visibilityTimeOutInMinutes * 60).ToString()); SetQueueAttributesRequest setQueueAttributesRequest = new SetQueueAttributesRequest(this.queueUrl, queueAttributes); SetQueueAttributesResponse setQueueAttributesResponse = this.sqsClient.SetQueueAttributes(setQueueAttributesRequest); if (setQueueAttributesResponse.HttpStatusCode != HttpStatusCode.OK) { throw new InvalidOperationException("Queue was created if not existed but unable to set visibility time out!"); } }
public override T Unmarshall <T>(IResponseContext context) { try { var response = new SetQueueAttributesResponse(); ResultUnmarshall(context, response); var xmlRootNode = GetXmlElement(context.ContentStream); response.ResponseMetadata.RequestId = xmlRootNode.SelectSingleNode("ResponseMetadata/RequestId")?.InnerText; return(response as T); } catch (Exception ex) { throw ErrorUnmarshall(ex.Message, ex, context.StatusCode); } }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { SetQueueAttributesResponse response = new SetQueueAttributesResponse(); while (context.Read()) { if (context.IsStartElement) { if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context); } } } return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, SetQueueAttributesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { } } return; }
public void Test_SetQueueAttributes_With_Multiple_Attributes_And_Check_For_Valid_Response() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; SetQueueAttributesResponse response = result as SetQueueAttributesResponse; if (null != response) { actualValue = true; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. SetQueueAttributesRequest request = new SetQueueAttributesRequest(); request.QueueUrl = string.Format("{0}/{1}", QueueURL, _queue_UnitTesting); request.Attribute.Add(new Amazon.SQS.Model.Attribute { Name = "VisibilityTimeout", Value = "3" }); request.Attribute.Add(new Amazon.SQS.Model.Attribute { Name = "MaximumMessageSize", Value = "6000" }); _client.SetQueueAttributes(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public SetQueueAttributesResponse AttachDeadLetterQueue(string queueName, string queueNameDeadLetter, int maxRetries) { GetQueueUrlResponse queueURL = SQSClient.GetQueueUrl(queueName); GetQueueUrlResponse queueURLDeadLetter = SQSClient.GetQueueUrl(queueNameDeadLetter); // Next, we need to get the the ARN (Amazon Resource Name) of our dead // letter queue so we can configure our main queue to deliver messages to it. IDictionary attributes = SQSClient.GetQueueAttributes(new GetQueueAttributesRequest() { QueueUrl = queueURLDeadLetter.QueueUrl, AttributeNames = new List <string>() { "QueueArn" } }).Attributes; string dlqArn = (string)attributes["QueueArn"]; // The last step is setting a RedrivePolicy on our main queue to configure // it to deliver messages to our dead letter queue if they haven't been // successfully processed after five attempts. string redrivePolicy = string.Format( "{{\"maxReceiveCount\":\"{0}\", \"deadLetterTargetArn\":\"{1}\"}}", maxRetries, dlqArn); SetQueueAttributesResponse awsSQAR = SQSClient.SetQueueAttributes(new SetQueueAttributesRequest() { QueueUrl = queueURL.QueueUrl, Attributes = new Dictionary <string, string>() { { "RedrivePolicy", redrivePolicy } } }); return(awsSQAR); }
public override WebServiceResponse Unmarshall(XmlUnmarshallerContext context) { SetQueueAttributesResponse response = new SetQueueAttributesResponse(); // Nothing need to do with this response here return response; }