首先,AWS C# SDK 会自我检查吗?现在,我有代码可以做类似的事情
md5检查
List<string> msgs = new List<string>();
ReceiveMessageResponse response = this.getMessageRoutine(num);
foreach (Message m in response.ReceiveMessageResult.Message) {
if (m.MD5OfBody.ToUpper() != Global.StringFunctions.CalculateMD5Hash(m.Body)) {
throw new Exception("TODO IMPLEMENT: RECEIVED MESSAGE IS CORRUPT");
}
msgs.Add(m.Body);
}
return msgs;
验证发出的用户定义的 ID 在响应中返回,并且服务器生成的消息的 md5 与发送的消息匹配
foreach (SendMessageBatchResultEntry e in response.SendMessageBatchResult.SendMessageBatchResultEntry) {
foreach (SendMessageBatchRequestEntry r in entry) {
if (r.Id == e.Id) {
if (Global.StringFunctions.CalculateMD5Hash(r.MessageBody) != e.MD5OfMessageBody.ToUpper()) {
throw new Exception("TODO IMPLEMENT THIS: MD5 MISMATCH BETWEEN AWS:LOCAL (" + e.MD5OfMessageBody.ToUpper() + " : " + Global.StringFunctions.CalculateMD5Hash(r.MessageBody)+")");
}
entry.Remove(r);
break;
}
throw new Exception("TODO IMPLEMENT THIS: INVALID ID IN RESPONSE");
}
}
if (entry.Count != 0) {
throw new Exception("TODO IMPLEMENT: NOT ALL MESSAGES SENT HAD A CORRESPONDING CALLBACK");
}
有没有更好的实现类似这样的东西,比如 request.checkResponse(response) ?