LrSqsSendMessageBatchRequestStatus.failed
Returns one LrSqsBatchErrorResultEntry element for each of the LrSqsMessages that were not sent successfully.
public Collection<LrSqsBatchErrorResultEntry> failed()
Return values
This function returns a collection of LrSqsBatchErrorResultEntry objects. Each LrSqsMessage that was not sent successfully using the sendMessageBatch API has a corresponding LrSqsBatchErrorResultEntry object in this collection.
Example
public int action() throws Throwable {
LrSqsClient.initClient(region, fifoQueueUrl);
LrSqsClient.initMessageBatch();
LrSqsClient.addMessageToBatch("batch message 0", "group1","dupID1");
LrSqsClient.addMessageToBatch("batch message 1","group1","dupID2");
HashMap<String, LrSqsMessageAttributeValue> messageAttributes = new HashMap<String, LrSqsMessageAttributeValue>();
messageAttributes.put("attr1", LrSqsClient.createMessageAttributeValueString("my string attribute value"));
messageAttributes.put("attr2", LrSqsClient.createMessageAttributeValueInt("1234"));
LrSqsClient.addMessageToBatchEx("batch message 2", "group1","dupID3", "specialId_inBatch", messageAttributes);
LrSqsSendMessageBatchRequestStatus batchResponse = LrSqsClient.sendMessageBatch();
if (batchResponse.hasSuccessful()){
Collection<LrSqsSendMessageBatchStatusEntry> successful_res = batchResponse.successful();
if (successful_res.size() > 3)
lr.error_message("batch size is not ok: " + successful_res.size());
for (LrSqsSendMessageBatchStatusEntry entry : successful_res){
lr.output_message("Message id within batch: " + entry.id());
lr.output_message("Message id: " + entry.messageId());
lr.output_message("Message sequence number: " + entry.messageId());
}
}
if (batchResponse.hasFailed()){
Collection<LrSqsBatchErrorResultEntry> failed_res = batchResponse.failed();
if (failed_res.size() > 3)
lr.error_message("batch size is not ok: " + failed_res.size());
for (LrSqsBatchErrorResultEntry entry : failed_res){
lr.output_message("Message id within batch: " + entry.id());
lr.output_message("Error code: " + entry.code());
lr.output_message("Error message: " + entry.message());
lr.output_message("Is it my fault? : " + entry.senderFault());
}
}
LrSqsClient.closeClient();
return 0;
}