LrSqsSendMessageBatchRequestStatus.hasSuccessful
Returns whether any LrSqsMessages were sent successfully.
public boolean hasSuccessful()
Return values
This function returns a Boolean value that represents whether any LrSqsMessage was sent successfully using the sendMessageBatch API.
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;
}