Skip to content

fix: add descriptive error message to SendBatchOperationFailedException#1624

Open
Baqirrizvidev wants to merge 1 commit into
awspring:mainfrom
Baqirrizvidev:fix/sqs-batch-failure-exception-message
Open

fix: add descriptive error message to SendBatchOperationFailedException#1624
Baqirrizvidev wants to merge 1 commit into
awspring:mainfrom
Baqirrizvidev:fix/sqs-batch-failure-exception-message

Conversation

@Baqirrizvidev
Copy link
Copy Markdown

This PR addresses Issue #1605 by constructing a detailed, descriptive exception message when creating a SendBatchOperationFailedException.

Problem

Previously, in AbstractMessagingTemplate.handleFailedSendBatch, a SendBatchOperationFailedException was created with a hardcoded empty string "" as the exception message. As a result, e.getMessage() returned "", rendering the exception silent in logs and requiring developers to manually extract details via e.getSendBatchResult().failed().

Solution

This PR updates AbstractMessagingTemplate to dynamically construct a diagnostic error message when a batch send operation fails. The message now contains:

  • The target SQS queue/endpoint.
  • The raw SQS message ID (or Spring message ID) of each failed message in the batch.
  • The associated failure error message returned from the SQS client.

Testing

  • Added assertions to the existing shouldThrowIfHasFailedMessagesInBatchByDefault unit test in SqsTemplateTests to verify that SendBatchOperationFailedException contains a message with the expected queue name, failed message ID, and SQS error details.
  • Verified that all unit tests pass successfully.

@github-actions github-actions Bot added the component: sqs SQS integration related issue label May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: sqs SQS integration related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant