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

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

Introduction

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

Prototype


public void setQueueUrl(String queueUrl) 

Source Link

Document

The URL of the Amazon SQS queue to which a message is sent.

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 .j  av  a 2  s.  co  m
        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:com.sitewhere.aws.SqsOutboundEventProcessor.java

License:Open Source License

/**
 * Send an event message to SQS.//  w  w w  .j  av a2 s .com
 * 
 * @param event
 * @throws SiteWhereException
 */
protected void sendSqsMessage(IDeviceEvent event) throws SiteWhereException {
    SendMessageRequest message = new SendMessageRequest();
    message.setMessageBody(MarshalUtils.marshalJsonAsString(event));
    message.setQueueUrl(getQueueUrl());
    SendMessageResult result = getSqs().sendMessage(message);
    LOGGER.debug("Sent SQS message with id: " + result.getMessageId());
}

From source file:org.apache.usergrid.apm.service.MetricsInjestionServiceSQSImpl.java

License:Apache License

public void sendData(String fullAppName, ClientMetricsEnvelope envelope) {
    try {//from  www . j  a va2 s  .c o  m
        SendMessageRequest sendMessageRequest = new SendMessageRequest();

        sendMessageRequest.setQueueUrl(AWSUtil.formFullQueueUrl(fullAppName));
        //String message = xStream.toXML(envelope);
        String message = objectMapper.writeValueAsString(envelope);
        sendMessageRequest.setMessageBody(message);
        int length = message.getBytes().length;
        log.info("Sending Message of size : " + length);
        this.sqsAsyncClient.sendMessage(sendMessageRequest);
    } catch (AmazonServiceException ce) {
        log.error("Queue does not exisit or is not accessible for AppId " + fullAppName, ce);
    } catch (JsonGenerationException e) {
        // TODO Auto-generated catch block
        log.error("Some Jackson Error: " + fullAppName, e);
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        log.error("Some Jackson Error: " + fullAppName, e);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.error("eror", e);
    }

}