Amazon SQS: Configure a Dead-Letter Queue
See more Amazon SQS Examples
Configure two existing queues in the same region. queue_url identifies the source; dlq_url identifies the dead-letter queue. GetQueueAttributes obtains their actual ARNs, then the code checks that both are standard or both FIFO. It replaces the DLQ RedriveAllowPolicy with byQueue for this source and replaces the source RedrivePolicy with that DLQ and maxReceiveCount=5. The outer Attributes values contain serialized JSON strings, not nested objects.
These writes are not atomic. Inspect both policies after propagation and reconcile partial failure before retrying. Include other permitted sources if the DLQ is shared; replacing its allow policy can otherwise remove their permission. Choose receive count and retention for the workload; for standard queues, DLQ retention should exceed source retention. A FIFO DLQ can break strict end-to-end processing order. This configures future failed-message routing; it does not move existing DLQ messages back.
Uses SQS's AWS JSON protocol: POST to the regional root / with Content-Type: application/x-amz-json-1.0 and an operation-specific X-Amz-Target: AmazonSQS.... Chilkat.Rest and AuthAws sign with AWS Signature Version 4, service sqs. AWS still supports the older Query/XML protocol; these examples use JSON for simpler request and response handling. No AWS SDK is required.
Provide current IAM credentials in a private qa_data/aws/sqs.json with string fields access_key, secret_key, and session_token for temporary credentials. Queue-specific examples also read queue_url from this file. Set the region in the code to match the queue. These examples use commercial regional endpoints; other partitions or custom endpoints require corresponding changes. Prefer short-lived role credentials. The file is explicitly loaded; profiles and credential refresh are not automatic. Keep it outside public content and source control. The temporary token is included in the signed query; keep URLs and diagnostics private. TLS certificate verification is enabled.
Transport completion, HTTP status, and response validity are checked separately. Use bounded backoff with jitter for retryable errors, and refresh expired credentials. A timed-out write or receive may already have been accepted. Standard queues can deliver duplicates: make application processing idempotent and delete only after successful processing. Automatic reconnection is disabled for writes and receives to avoid replay after a lost response. Read-only queue listing permits reconnection.
Requires sqs:GetQueueAttributes and sqs:SetQueueAttributes on the relevant queues. Scope access to the intended queue. Customer-managed KMS encryption can require additional KMS permissions for producers and consumers.
AWS SetQueueAttributes reference
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loTextCompare
LOCAL loCredentials
LOCAL lnSameText1
LOCAL lnSameText2
LOCAL lcRegion
LOCAL loEndpoint
LOCAL lcQueueUrl
LOCAL lnSameText3
LOCAL loExpectedPrefix
LOCAL loQueueText
LOCAL loAws
LOCAL loRest
LOCAL lnSameText4
LOCAL loConnection
LOCAL loBody
LOCAL loResult
LOCAL loRequestBody
LOCAL loResponseBody
LOCAL lcDlqUrl
LOCAL lnSameText5
LOCAL lnSameText6
LOCAL loDlqText
LOCAL lnSameText7
LOCAL lcSourceArn
LOCAL lnSameText8
LOCAL lcDlqArn
LOCAL lnSameText9
LOCAL loSourceArnText
LOCAL loDlqArnText
LOCAL lnSourceIsFifo
LOCAL lnDlqIsFifo
LOCAL loAllowPolicy
LOCAL loRedrivePolicy
lnSuccess = 0
* StringBuilder compares text by value in every generated language.
loTextCompare = CreateObject('Chilkat.StringBuilder')
* Assumes Chilkat is unlocked. See Global Unlock Sample.
lnSuccess = 0
* Private configuration, not a file in public web content or source control.
* Load current IAM credentials authorized for the SQS operation.
loCredentials = CreateObject('Chilkat.JsonObject')
loCredentials.Strict = 1
lnSuccess = loCredentials.LoadFile("qa_data/aws/sqs.json")
IF (lnSuccess <> 1) THEN
? "Could not load private AWS credentials."
RELEASE loTextCompare
RELEASE loCredentials
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(loCredentials.StringOf("access_key"))
lnSameText1 = loTextCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("access_key") <> 1) OR (lnSameText1 = 1)) THEN
? "Missing or invalid access_key."
RELEASE loTextCompare
RELEASE loCredentials
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(loCredentials.StringOf("secret_key"))
lnSameText2 = loTextCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("secret_key") <> 1) OR (lnSameText2 = 1)) THEN
? "Missing or invalid secret_key."
RELEASE loTextCompare
RELEASE loCredentials
CANCEL
ENDIF
* Set this once to the region containing the queue.
lcRegion = "us-west-2"
loEndpoint = CreateObject('Chilkat.StringBuilder')
lnSuccess = loEndpoint.Append("sqs.")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
CANCEL
ENDIF
lnSuccess = loEndpoint.Append(lcRegion)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
CANCEL
ENDIF
lnSuccess = loEndpoint.Append(".amazonaws.com")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
CANCEL
ENDIF
* Use the exact QueueUrl returned by CreateQueue, GetQueueUrl, or ListQueues.
* This example targets a standard commercial regional endpoint, not a custom endpoint.
lcQueueUrl = loCredentials.StringOf("queue_url")
loTextCompare.Clear()
loTextCompare.SetString(lcQueueUrl)
lnSameText3 = loTextCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("queue_url") <> 1) OR (lnSameText3 = 1)) THEN
? "Missing or invalid queue_url in sqs.json."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
CANCEL
ENDIF
loExpectedPrefix = CreateObject('Chilkat.StringBuilder')
lnSuccess = loExpectedPrefix.Append("https://")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
CANCEL
ENDIF
lnSuccess = loExpectedPrefix.Append(loEndpoint.GetAsString())
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
CANCEL
ENDIF
lnSuccess = loExpectedPrefix.Append("/")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
CANCEL
ENDIF
loQueueText = CreateObject('Chilkat.StringBuilder')
lnSuccess = loQueueText.Append(lcQueueUrl)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
CANCEL
ENDIF
IF (loQueueText.StartsWith(loExpectedPrefix.GetAsString(),1) <> 1) THEN
? "Queue URL must use HTTPS and the configured SQS region."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
CANCEL
ENDIF
loAws = CreateObject('Chilkat.AuthAws')
loAws.AccessKey = loCredentials.StringOf("access_key")
loAws.SecretKey = loCredentials.StringOf("secret_key")
loAws.Region = lcRegion
loAws.ServiceName = "sqs"
loAws.SignatureVersion = 4
loRest = CreateObject('Chilkat.Rest')
loRest.ConnectTimeoutMs = 20000
loRest.IdleTimeoutMs = 60000
lnSuccess = loRest.SetAuthAws(loAws)
IF (lnSuccess <> 1) THEN
? "Could not configure AWS signing."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
CANCEL
ENDIF
* Temporary IAM/STS credentials require their session token on every signed request.
* AddQueryParam includes it in SigV4's canonical query. Never log the request URL.
* Leave session_token absent or empty only for credentials that do not have one.
IF (loCredentials.HasMember("session_token") = 1) THEN
IF (loCredentials.JsonTypeOf("session_token") <> 1) THEN
? "session_token must be a string."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(loCredentials.StringOf("session_token"))
lnSameText4 = loTextCompare.ContentsEqual("",1)
IF (lnSameText4 <> 1) THEN
lnSuccess = loRest.AddQueryParam("X-Amz-Security-Token",loCredentials.StringOf("session_token"))
IF (lnSuccess <> 1) THEN
? "Could not set the session-token parameter."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
CANCEL
ENDIF
ENDIF
ENDIF
* Supply a Socket to explicitly enable TLS certificate verification.
loConnection = CreateObject('Chilkat.Socket')
loConnection.RequireSslCertVerify = 1
loConnection.MaxReadIdleMs = 60000
loConnection.MaxSendIdleMs = 60000
lnSuccess = loConnection.Connect(loEndpoint.GetAsString(),443,1,20000)
IF (lnSuccess <> 1) THEN
? "TLS connection failed; inspect diagnostics privately."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
CANCEL
ENDIF
* Do not automatically reconnect/replay a write or receive after a lost response.
lnSuccess = loRest.UseConnection(loConnection,0)
IF (lnSuccess <> 1) THEN
? "Could not attach the TLS connection."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("Content-Type","application/x-amz-json-1.0")
IF (lnSuccess <> 1) THEN
? "Could not set the content type."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
CANCEL
ENDIF
loBody = CreateObject('Chilkat.JsonObject')
loResult = CreateObject('Chilkat.JsonObject')
loResult.Strict = 1
loRequestBody = CreateObject('Chilkat.StringBuilder')
loResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loRest.AddHeader("X-Amz-Target","AmazonSQS.GetQueueAttributes")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("QueueUrl",lcQueueUrl)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
CANCEL
ENDIF
lcDlqUrl = loCredentials.StringOf("dlq_url")
loTextCompare.Clear()
loTextCompare.SetString(lcDlqUrl)
lnSameText5 = loTextCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("dlq_url") <> 1) OR (lnSameText5 = 1)) THEN
? "Supply dlq_url in the private configuration."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(lcDlqUrl)
lnSameText6 = loTextCompare.ContentsEqual(lcQueueUrl,1)
IF (lnSameText6 = 1) THEN
? "Source queue and dead-letter queue must differ."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
CANCEL
ENDIF
loDlqText = CreateObject('Chilkat.StringBuilder')
lnSuccess = loDlqText.Append(lcDlqUrl)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
IF (loDlqText.StartsWith(loExpectedPrefix.GetAsString(),1) <> 1) THEN
? "DLQ URL must use the configured region."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("AttributeNames[0]","QueueArn")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
* EmitSb appends, so clear both builders before each request/page.
loRequestBody.Clear()
loResponseBody.Clear()
lnSuccess = loBody.EmitSb(loRequestBody)
IF (lnSuccess <> 1) THEN
? "Could not serialize JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loRest.FullRequestSb("POST","/",loRequestBody,loResponseBody)
IF (lnSuccess <> 1) THEN
? "Request did not complete; inspect diagnostics privately."
* A write or receive may have reached SQS. Do not blindly replay it.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "SQS HTTP status: " + STR(loRest.ResponseStatusCode)
? "AWS request ID: " + loRest.ResponseHdrByName("x-amzn-RequestId")
lnSuccess = loResult.LoadSb(loResponseBody)
IF ((lnSuccess = 1) AND (loResult.JsonTypeOf("__type") = 1)) THEN
? "AWS error type: " + loResult.StringOf("__type")
ELSE
? "AWS error type: " + loRest.ResponseHdrByName("x-amzn-errortype")
ENDIF
* Error messages, payloads, receipt handles and signed URLs can be private.
* HTTP 400 can be throttling, expired credentials, or invalid parameters.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loResponseBody.Trim()
IF (lnSuccess <> 1) THEN
? "Could not inspect response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
IF (loResponseBody.StartsWith("{",1) <> 1) THEN
? "Expected a JSON object response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loResult.LoadSb(loResponseBody)
IF (lnSuccess <> 1) THEN
? "Expected well-formed JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(loResult.StringOf("Attributes.QueueArn"))
lnSameText7 = loTextCompare.ContentsEqual("",1)
IF ((loResult.JsonTypeOf("Attributes.QueueArn") <> 1) OR (lnSameText7 = 1)) THEN
? "Missing or invalid Attributes.QueueArn."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lcSourceArn = loResult.StringOf("Attributes.QueueArn")
* This is a distinct, deliberate next operation, not replay of a failed request.
loRest.Disconnect(10)
lnSuccess = loConnection.Connect(loEndpoint.GetAsString(),443,1,20000)
IF (lnSuccess <> 1) THEN
? "TLS reconnection failed."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loRest.UseConnection(loConnection,0)
IF (lnSuccess <> 1) THEN
? "Could not attach the TLS connection."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("X-Amz-Target","AmazonSQS.GetQueueAttributes")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loBody.Load("{}")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("QueueUrl",lcDlqUrl)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("AttributeNames[0]","QueueArn")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
* EmitSb appends, so clear both builders before each request/page.
loRequestBody.Clear()
loResponseBody.Clear()
lnSuccess = loBody.EmitSb(loRequestBody)
IF (lnSuccess <> 1) THEN
? "Could not serialize JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loRest.FullRequestSb("POST","/",loRequestBody,loResponseBody)
IF (lnSuccess <> 1) THEN
? "Request did not complete; inspect diagnostics privately."
* A write or receive may have reached SQS. Do not blindly replay it.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "SQS HTTP status: " + STR(loRest.ResponseStatusCode)
? "AWS request ID: " + loRest.ResponseHdrByName("x-amzn-RequestId")
lnSuccess = loResult.LoadSb(loResponseBody)
IF ((lnSuccess = 1) AND (loResult.JsonTypeOf("__type") = 1)) THEN
? "AWS error type: " + loResult.StringOf("__type")
ELSE
? "AWS error type: " + loRest.ResponseHdrByName("x-amzn-errortype")
ENDIF
* Error messages, payloads, receipt handles and signed URLs can be private.
* HTTP 400 can be throttling, expired credentials, or invalid parameters.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loResponseBody.Trim()
IF (lnSuccess <> 1) THEN
? "Could not inspect response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
IF (loResponseBody.StartsWith("{",1) <> 1) THEN
? "Expected a JSON object response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lnSuccess = loResult.LoadSb(loResponseBody)
IF (lnSuccess <> 1) THEN
? "Expected well-formed JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(loResult.StringOf("Attributes.QueueArn"))
lnSameText8 = loTextCompare.ContentsEqual("",1)
IF ((loResult.JsonTypeOf("Attributes.QueueArn") <> 1) OR (lnSameText8 = 1)) THEN
? "Missing or invalid Attributes.QueueArn."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
lcDlqArn = loResult.StringOf("Attributes.QueueArn")
loTextCompare.Clear()
loTextCompare.SetString(lcSourceArn)
lnSameText9 = loTextCompare.ContentsEqual(lcDlqArn,1)
IF (lnSameText9 = 1) THEN
? "Source and DLQ ARNs must differ."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
CANCEL
ENDIF
loSourceArnText = CreateObject('Chilkat.StringBuilder')
loDlqArnText = CreateObject('Chilkat.StringBuilder')
lnSuccess = loSourceArnText.Append(lcSourceArn)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
CANCEL
ENDIF
lnSuccess = loDlqArnText.Append(lcDlqArn)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
CANCEL
ENDIF
lnSourceIsFifo = loSourceArnText.EndsWith(".fifo",1)
lnDlqIsFifo = loDlqArnText.EndsWith(".fifo",1)
IF (lnSourceIsFifo <> lnDlqIsFifo) THEN
? "Source and DLQ must both be standard or both FIFO."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
CANCEL
ENDIF
* Replace the DLQ allow policy with a policy permitting THIS source only.
* If other sources use this DLQ, include them too before applying the policy.
loAllowPolicy = CreateObject('Chilkat.JsonObject')
lnSuccess = loAllowPolicy.UpdateString("redrivePermission","byQueue")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loAllowPolicy.UpdateString("sourceQueueArns[0]",lcSourceArn)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
* This is a distinct, deliberate next operation, not replay of a failed request.
loRest.Disconnect(10)
lnSuccess = loConnection.Connect(loEndpoint.GetAsString(),443,1,20000)
IF (lnSuccess <> 1) THEN
? "TLS reconnection failed."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loRest.UseConnection(loConnection,0)
IF (lnSuccess <> 1) THEN
? "Could not attach the TLS connection."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("X-Amz-Target","AmazonSQS.SetQueueAttributes")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loBody.Load("{}")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("QueueUrl",lcDlqUrl)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("Attributes.RedriveAllowPolicy",loAllowPolicy.Emit())
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
* EmitSb appends, so clear both builders before each request/page.
loRequestBody.Clear()
loResponseBody.Clear()
lnSuccess = loBody.EmitSb(loRequestBody)
IF (lnSuccess <> 1) THEN
? "Could not serialize JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loRest.FullRequestSb("POST","/",loRequestBody,loResponseBody)
IF (lnSuccess <> 1) THEN
? "Request did not complete; inspect diagnostics privately."
* A write or receive may have reached SQS. Do not blindly replay it.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "SQS HTTP status: " + STR(loRest.ResponseStatusCode)
? "AWS request ID: " + loRest.ResponseHdrByName("x-amzn-RequestId")
lnSuccess = loResult.LoadSb(loResponseBody)
IF ((lnSuccess = 1) AND (loResult.JsonTypeOf("__type") = 1)) THEN
? "AWS error type: " + loResult.StringOf("__type")
ELSE
? "AWS error type: " + loRest.ResponseHdrByName("x-amzn-errortype")
ENDIF
* Error messages, payloads, receipt handles and signed URLs can be private.
* HTTP 400 can be throttling, expired credentials, or invalid parameters.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
* This operation normally returns an empty HTTP body on success.
* Also accept an empty JSON object; never require XML for this protocol.
IF (loResponseBody.Length > 0) THEN
lnSuccess = loResponseBody.Trim()
IF (lnSuccess <> 1) THEN
? "Could not inspect response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
IF (loResponseBody.StartsWith("{",1) <> 1) THEN
? "Expected a JSON object response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
lnSuccess = loResult.LoadSb(loResponseBody)
IF (lnSuccess <> 1) THEN
? "Expected well-formed JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
IF (loResult.Size <> 0) THEN
? "Unexpected fields in the empty-result response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
CANCEL
ENDIF
ENDIF
? "DLQ allow-policy update accepted. The source policy has not been updated yet."
loRedrivePolicy = CreateObject('Chilkat.JsonObject')
lnSuccess = loRedrivePolicy.UpdateString("deadLetterTargetArn",lcDlqArn)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loRedrivePolicy.UpdateInt("maxReceiveCount",5)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
* This is a distinct, deliberate next operation, not replay of a failed request.
loRest.Disconnect(10)
lnSuccess = loConnection.Connect(loEndpoint.GetAsString(),443,1,20000)
IF (lnSuccess <> 1) THEN
? "TLS reconnection failed."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loRest.UseConnection(loConnection,0)
IF (lnSuccess <> 1) THEN
? "Could not attach the TLS connection."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("X-Amz-Target","AmazonSQS.SetQueueAttributes")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loBody.Load("{}")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("QueueUrl",lcQueueUrl)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loBody.UpdateString("Attributes.RedrivePolicy",loRedrivePolicy.Emit())
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
* EmitSb appends, so clear both builders before each request/page.
loRequestBody.Clear()
loResponseBody.Clear()
lnSuccess = loBody.EmitSb(loRequestBody)
IF (lnSuccess <> 1) THEN
? "Could not serialize JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loRest.FullRequestSb("POST","/",loRequestBody,loResponseBody)
IF (lnSuccess <> 1) THEN
? "Request did not complete; inspect diagnostics privately."
* A write or receive may have reached SQS. Do not blindly replay it.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "SQS HTTP status: " + STR(loRest.ResponseStatusCode)
? "AWS request ID: " + loRest.ResponseHdrByName("x-amzn-RequestId")
lnSuccess = loResult.LoadSb(loResponseBody)
IF ((lnSuccess = 1) AND (loResult.JsonTypeOf("__type") = 1)) THEN
? "AWS error type: " + loResult.StringOf("__type")
ELSE
? "AWS error type: " + loRest.ResponseHdrByName("x-amzn-errortype")
ENDIF
* Error messages, payloads, receipt handles and signed URLs can be private.
* HTTP 400 can be throttling, expired credentials, or invalid parameters.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
* This operation normally returns an empty HTTP body on success.
* Also accept an empty JSON object; never require XML for this protocol.
IF (loResponseBody.Length > 0) THEN
lnSuccess = loResponseBody.Trim()
IF (lnSuccess <> 1) THEN
? "Could not inspect response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
IF (loResponseBody.StartsWith("{",1) <> 1) THEN
? "Expected a JSON object response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
lnSuccess = loResult.LoadSb(loResponseBody)
IF (lnSuccess <> 1) THEN
? "Expected well-formed JSON."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
IF (loResult.Size <> 0) THEN
? "Unexpected fields in the empty-result response."
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy
CANCEL
ENDIF
ENDIF
? "Source redrive-policy update accepted. Read both policies after propagation."
* These two writes are not a transaction. A later failure leaves the earlier change.
RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loExpectedPrefix
RELEASE loQueueText
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loBody
RELEASE loResult
RELEASE loRequestBody
RELEASE loResponseBody
RELEASE loDlqText
RELEASE loSourceArnText
RELEASE loDlqArnText
RELEASE loAllowPolicy
RELEASE loRedrivePolicy