Example usage for com.amazonaws.services.sqs.model SendMessageRequest setDelaySeconds

List of usage examples for com.amazonaws.services.sqs.model SendMessageRequest setDelaySeconds

Introduction

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

Prototype


public void setDelaySeconds(Integer delaySeconds) 

Source Link

Document

The length of time, in seconds, for which to delay a specific message.

Usage

From source file:com.eucalyptus.portal.SimpleQueueClientManager.java

License:Open Source License

public void sendMessage(final String queueName, final String message) throws Exception {
    try {/*from   w  w  w .ja  v  a  2s  . c  om*/
        final SendMessageRequest req = new SendMessageRequest();
        req.setQueueUrl(getQueueUrl(queueName));
        req.setDelaySeconds(0);
        req.setMessageBody(message);
        getSimpleQueueClient().sendMessage(req);
    } catch (final AmazonServiceException ex) {
        throw new Exception("Failed to send message due to service error", ex);
    } catch (final AmazonClientException ex) {
        throw new Exception("Failed to send message due to client error", ex);
    }
}

From source file:org.apache.camel.component.aws.sqs.SqsProducer.java

License:Apache License

private void addDelay(SendMessageRequest request, Exchange exchange) {
    Integer headerValue = exchange.getIn().getHeader(SqsConstants.DELAY_HEADER, Integer.class);
    Integer delayValue = Integer.valueOf(0);
    if (headerValue == null) {
        LOG.trace("Using the config delay");
        delayValue = getEndpoint().getConfiguration().getDelaySeconds();
    } else {/*  w  w  w.  jav a2  s  . c om*/
        LOG.trace("Using the header delay");
        delayValue = headerValue;
    }
    LOG.trace("found delay: " + delayValue);
    request.setDelaySeconds(delayValue == null ? Integer.valueOf(0) : delayValue);
}