private static void sendMessageBatchOperationMd5Check ( SendMessageBatchRequest sendMessageBatchRequest , SendMessageBatchResult sendMessageBatchResult ) { Map < String , SendMessageBatchRequestEntry > idToRequestEntryMap = new HashMap < String , SendMessageBatchRequestEntry > ( ) ; if ( sendMessageBatchRequest . getEntries ( ) != null ) { for ( SendMessageBatchRequestEntry entry : sendMessageBatchRequest . getEntries ( ) ) { idToRequestEntryMap . put ( entry . getId ( ) , entry ) ; } } if ( sendMessageBatchResult . getSuccessful ( ) != null ) { for ( SendMessageBatchResultEntry entry : sendMessageBatchResult . getSuccessful ( ) ) { String messageBody = idToRequestEntryMap . get ( entry . getId ( ) ) . getMessageBody ( ) ; String bodyMd5Returned = entry . getMD5OfMessageBody ( ) ; String clientSideBodyMd5 = calculateMessageBodyMd5 ( messageBody ) ; if ( ! clientSideBodyMd5 . equals ( bodyMd5Returned ) ) { throw new AmazonClientException ( String . format ( MD5_MISMATCH_ERROR_MESSAGE_WITH_ID , MESSAGE_BODY , entry . getId ( ) , clientSideBodyMd5 , bodyMd5Returned ) ) ; } Map < String , MessageAttributeValue > messageAttr = idToRequestEntryMap . get ( entry . getId ( ) ) . getMessageAttributes ( ) ; if ( messageAttr != null && ! messageAttr . isEmpty ( ) ) { String attrMd5Returned = entry . getMD5OfMessageAttributes ( ) ; String clientSideAttrMd5 = calculateMessageAttributesMd5 ( messageAttr ) ; if ( ! clientSideAttrMd5 . equals ( attrMd5Returned ) ) { throw new AmazonClientException ( String . format ( MD5_MISMATCH_ERROR_MESSAGE_WITH_ID , MESSAGE_ATTRIBUTES , entry . getId ( ) , clientSideAttrMd5 , attrMd5Returned ) ) ; } } } } }
Throw an exception if the MD5 checksums returned in the SendMessageBatchResult do not match the client - side calculation based on the original messages in the SendMessageBatchRequest .