我一直在努力删除从AWS队列收到的消息。
我使用的功能是:
<cffunction name="deleteMessage" output="true" returntype="void">
<cfargument name="uri" type="string" required="true">
<cfargument name="messageId" type="string" required="true">
<cfset var tmp = StructNew()/>
<cfset tmp.dateTimeString = zuluDateTimeFormat(Now())/>
<cfset tmp.fixedData = "ActionDeleteMessage" &
"AWSAccessKeyId#This.awsAccessKeyId#" &
"MessageHandle#Arguments.messageId#" &
"SignatureVersion1" &
"Timestamp#tmp.dateTimeString#" &
"Version#This.sqsVersion#"/>
<cfset tmp.signature = createSignature(tmp.fixedData)/>
<cfhttp method="GET" url="#Arguments.host#" charset="UTF-8">
<cfhttpparam type="url" name="Action" value="DeleteMessage"/>
<cfhttpparam type="url" name="AWSAccessKeyId" value="#This.awsAccessKeyId#"/>
<cfhttpparam type="url" name="MessageHandle" value="#Arguments.messageId#"/>
<cfhttpparam type="url" name="Signature" value="#tmp.signature#"/>
<cfhttpparam type="url" name="SignatureVersion" value="1"/>
<cfhttpparam type="url" name="Timestamp" value="#tmp.dateTimeString#"/>
<cfhttpparam type="url" name="Version" value="#This.sqsVersion#"/>
</cfhttp>
<cfdump var="#CFHTTP.FileContent#"><cfabort>
<cfif CFHTTP.ResponseHeader.Status_Code neq 200>
<cfinvoke method="handleErrors"
content="#CFHTTP.FileContent#"
/>
<cfelse>
<cfreturn XmlParse(CFHTTP.FileContent).deleteMessageResponse.return.XmlText/>
</cfif>
</cffunction>
所有细节都正确传递,签名也正在成功生成(通过其他AWS调用验证)。我从亚马逊回来的错误信息是:
<?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2008-01-01/"><Error><Type>Sender</Type><Code>MissingParameter</Code><Message>The request must contain the parameter MessageHandle.</Message><Detail/></Error><RequestId>1a144095-db82-59c1-9551-116614ba674d</RequestId></ErrorResponse>
如何更正此问题并正确删除邮件?
答案 0 :(得分:1)
原则上你在请求中需要MessageHandle和ReceiptHandle:
<cffunction name="deleteMessage" output="true" returntype="void">
<cfargument name="uri" type="string" required="true">
<cfargument name="messageId" type="string" required="true">
<cfargument name="receiptHandle" type="string" required="true">
<cfset var tmp = StructNew()/>
<cfset tmp.dateTimeString = zuluDateTimeFormat(Now())/>
<cfset tmp.fixedData = "ActionDeleteMessage" &
"AWSAccessKeyId#This.awsAccessKeyId#" &
"MessageHandle#Arguments.messageId#" &
"ReceiptHandle#Arguments.receiptHandle#" &
"SignatureVersion1" &
"Timestamp#tmp.dateTimeString#" &
"Version#This.sqsVersion#"/>
<cfset tmp.signature = createSignature(tmp.fixedData)/>
<cfhttp method="GET" url="#Arguments.host#" charset="UTF-8">
<cfhttpparam type="url" name="Action" value="DeleteMessage"/>
<cfhttpparam type="url" name="AWSAccessKeyId" value="#This.awsAccessKeyId#"/>
<cfhttpparam type="url" name="MessageHandle" value="#Arguments.messageId#"/>
<cfhttpparam type="url" name="ReceiptHandle" value="#Arguments.receiptHandle#"/>
<cfhttpparam type="url" name="Signature" value="#tmp.signature#"/>
<cfhttpparam type="url" name="SignatureVersion" value="1"/>
<cfhttpparam type="url" name="Timestamp" value="#tmp.dateTimeString#"/>
<cfhttpparam type="url" name="Version" value="#This.sqsVersion#"/>
</cfhttp>
<cfdump var="#CFHTTP.FileContent#"><cfabort>
<cfif CFHTTP.ResponseHeader.Status_Code neq 200>
<cfinvoke method="handleErrors"
content="#CFHTTP.FileContent#"
/>
<cfelse>
<cfreturn XmlParse(CFHTTP.FileContent).deleteMessageResponse.return.XmlText/>
</cfif>
</cffunction>