Package com.amazonaws.services.sqs.model

Examples of com.amazonaws.services.sqs.model.SendMessageRequest


    }

    private void sendSomeMessages(AmazonSQS sqs) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        sqs.sendMessage(new SendMessageRequest(Constants.QUEUE_URL,
                "a random message sent at " + format.format(new Date())));
    }
View Full Code Here


        }
       
    }

    private void sendMessage(String url, AbstractMessage message) {
        SendMessageRequest sqsRequest = null;
       
        try {
            String payload = new ObjectMapper().writeValueAsString(message);
       
            if(log.isDebugEnabled()) {
                log.debug("Sending SQS: " + payload);
            }
           
            sqsRequest = new SendMessageRequest(url, payload);
        } catch (IOException e) {
            log.error("Failed to map json object.", e);
        }
       
        sqs.sendMessage(sqsRequest);
View Full Code Here

        // SendMessage
          if (request.getOriginalRequest() instanceof SendMessageRequest
              && response instanceof SendMessageResult) {
            if (log.isDebugEnabled())
              log.debug("Checking the MD5 digest returned in SendMessageResult.");
            SendMessageRequest sendMessageRequest = (SendMessageRequest)request.getOriginalRequest();
            SendMessageResult sendMessageResult = (SendMessageResult)response;
            String messageSent = sendMessageRequest.getMessageBody();
            String md5Returned = sendMessageResult.getMD5OfMessageBody();
            if ( !checkMessageMd5(messageSent, md5Returned) )
              throw new AmazonClientException("MD5 returned by SQS does not match the calculation on the original request.(Message body: \""
                  + messageSent + "\", MD5 returned: \"" + md5Returned + "\")");
          }
View Full Code Here

  public Object executeOutboundOperation(final Message<?> message) {

    try {
      String serializedMessage = messageMarshaller.serialize(message);
      if (queue == null) {
        SendMessageRequest request = new SendMessageRequest(queueUrl,
            serializedMessage);
        SendMessageResult result = sqsClient.sendMessage(request);
        log.debug("Message sent, Id:" + result.getMessageId());
      } else {
        queue.add(serializedMessage);
View Full Code Here

    if (!StringUtils.isBlank(url) && task != null) {
      // only allow strings - ie JSON
      if (!StringUtils.isBlank(task)) {
        // Send a message
        try {
          SendMessageRequest sendReq = new SendMessageRequest();
          sendReq.setQueueUrl(url);
          sendReq.setMessageBody(task);

          sqs.sendMessage(sendReq);
        } catch (AmazonServiceException ase) {
          logException(ase);
        } catch (AmazonClientException ace) {
View Full Code Here

            // SendMessage
            if (request.getOriginalRequest() instanceof SendMessageRequest
                    && response instanceof SendMessageResult) {
                if (log.isDebugEnabled())
                    log.debug("Checking the MD5 digest returned in SendMessageResult.");
                SendMessageRequest sendMessageRequest = (SendMessageRequest)request.getOriginalRequest();
                SendMessageResult sendMessageResult = (SendMessageResult)response;
                String messageSent = sendMessageRequest.getMessageBody();
                String md5Returned = sendMessageResult.getMD5OfMessageBody();
                if ( !checkMessageMd5(messageSent, md5Returned) )
                    throw new AmazonClientException("MD5 returned by SQS does not match the calculation on the original request.(Message body: \""
                            + messageSent + "\", MD5 returned: \"" + md5Returned + "\")");
            }
View Full Code Here

     
        if (useInlineApiCalls) {
          receiptHandle = CQSAPI.sendMessage(cnsInternal.getUserId(), relativeQueueUrl, message, null);
        } else {
          String absoluteQueueUrl = Util.getAbsoluteQueueUrlForRelativeUrl(relativeQueueUrl);
          SendMessageResult sendMessageResult = sqs.sendMessage(new SendMessageRequest(absoluteQueueUrl, message));
          receiptHandle = sendMessageResult.getMessageId();
        }
       
        long ts2 = System.currentTimeMillis();
       
View Full Code Here

     
      public void run() {
        try {
          logger.info("starting sending messages");
          for (int i=0; i<count; i++) {
          currentSqs.sendMessage(new SendMessageRequest(queueUrl, "test message " + i));
          }
      } catch (Exception ex) {
        logger.error("error", ex);
      }
      }
View Full Code Here

      receiveMessageRequest.setMaxNumberOfMessages(1);
      receiveMessageRequest.setWaitTimeSeconds(20);
     
      long start = System.currentTimeMillis();
     
            cqs1.sendMessage(new SendMessageRequest(queueUrl, "test message"));
     
      logger.info("calling receive message");
     
      ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);
     
View Full Code Here

          }
         
          Thread.sleep(2000);
         
        for (int i=0; i<numMessages; i++) {
          senderSqs.sendMessage(new SendMessageRequest(queueUrl, "test message " + i));
      }
       
        Thread.sleep(1000);
       
        assertTrue("Wrong number of messages: " + messageMap.size(), messageMap.size() == numMessages);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.sqs.model.SendMessageRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.