Example usage for com.amazonaws.services.sqs.model.transform ReceiveMessageResultStaxUnmarshaller ReceiveMessageResultStaxUnmarshaller

List of usage examples for com.amazonaws.services.sqs.model.transform ReceiveMessageResultStaxUnmarshaller ReceiveMessageResultStaxUnmarshaller

Introduction

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

Prototype

ReceiveMessageResultStaxUnmarshaller

Source Link

Usage

From source file:com.kolich.aws.services.sqs.impl.KolichSQSClient.java

License:Open Source License

@Override
public Either<HttpFailure, ReceiveMessageResult> receiveMessage(final URI queueURI,
        final Integer longPollWaitSecs, final Integer maxNumberOfMessages) {
    return new AwsSQSHttpClosure<ReceiveMessageResult>(client_, SC_OK,
            new ReceiveMessageResultStaxUnmarshaller()) {
        @Override// w w  w  .  j ava  2  s  .c  o  m
        public void validate() throws Exception {
            checkNotNull(queueURI, "Queue URI cannot be null.");
            if (longPollWaitSecs != null) {
                checkState(longPollWaitSecs <= SQS_MAX_LONG_POLL_WAIT_TIME_SECS,
                        "Cannot long poll wait on a queue longer than (secs): "
                                + SQS_MAX_LONG_POLL_WAIT_TIME_SECS);
            }
            if (maxNumberOfMessages != null) {
                checkState(maxNumberOfMessages <= SQS_MAX_MESSAGES_PER_REQUEST,
                        "Max number of messages to receive cannot be greater than: "
                                + SQS_MAX_MESSAGES_PER_REQUEST);
            }
        }

        @Override
        public void prepare(final AwsHttpRequest request) throws Exception {
            request.addParameter(SQS_ACTION_PARAM, SQS_ACTION_RECEIVE_MESSAGE);
            if (longPollWaitSecs != null) {
                request.addParameter(SQS_LONG_POLL_WAIT_TIME_PARAM, Integer.toString(longPollWaitSecs));
            }
            if (maxNumberOfMessages != null) {
                request.addParameter(SQS_MAX_MESSAGES_PARAM, Integer.toString(maxNumberOfMessages));
            }
        }
    }.post(queueURI);
}