Share this page

# LrSqsSendMessageBatchRequestStatus.successful

Returns one LrSqsSendMessageBatchStatusEntry element for each of the LrSqsMessages that were sent successfully.

`public Collection<LrSqsSendMessageBatchStatusEntry> successful()`

## Return values

This function returns a collection of LrSqsSendMessageBatchStatusEntry objects. Each LrSqsMessage that was sent successfully using the sendMessageBatch API has a corresponding LrSqsSendMessageBatchStatusEntry object in this collection.

## Example

Copy code

    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;
        }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: