Example usage for com.amazonaws.services.sqs.model SendMessageBatchResult getSuccessful

List of usage examples for com.amazonaws.services.sqs.model SendMessageBatchResult getSuccessful

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs.model SendMessageBatchResult getSuccessful.

Prototype


public java.util.List<SendMessageBatchResultEntry> getSuccessful() 

Source Link

Document

A list of SendMessageBatchResultEntry items.

Usage

From source file:com.dushyant.flume.sink.aws.sqs.BatchSQSMsgSender.java

License:Apache License

@Override
public int send(Channel channel) throws EventDeliveryException {
    int eventProcessedCounter = 0;
    // Create batch request
    List<SendMessageBatchRequest> batchRequests = createBatches(channel);

    for (SendMessageBatchRequest batchRequest : batchRequests) {
        // Send batch request
        SendMessageBatchResult result = null;
        try {/*  w w w.  ja  va  2s.co  m*/
            result = this.amazonSQS.sendMessageBatch(batchRequest);
        } catch (AmazonServiceException ase) {
            // Throw request reached to SQS but the whole batch was rejected for some reason. Let the whole batch
            // be treated as "failed". Flume will retry the while batch
            throw new EventDeliveryException("Failure sending batch message request to Amazon SQS, "
                    + "the request made it to SQS but was rejected for some reason.", ase);
        } catch (AmazonClientException ace) {
            throw new EventDeliveryException("Failure sending batch message request to Amazon SQS.", ace);
        }

        // Handle the result of the SQS batch request i.e., log errors, or fail the whole batch by throwing
        // EventDeliveryException in case of errors etc.
        handleResult(batchRequest, result);

        // The code reached here means there is nothing to rollback in this transaction. So increment the
        // eventProcessedCounter by the number of successfully sent messages.
        eventProcessedCounter += result.getSuccessful().size();
    }
    return eventProcessedCounter;
}

From source file:smartthings.brave.sqs.AmazonSQSClientParser.java

License:Apache License

public void response(SendMessageBatchResult result, SpanCustomizer customizer) {
    for (SendMessageBatchResultEntry entry : result.getSuccessful()) {
        customizer.tag(AmazonSQSTraceKeys.SQS_MESSAGE_ID, entry.getMessageId());
    }/*from   w w w .  jav  a 2 s. c  o  m*/
}