Package com.amazonaws.services.sqs.model

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


           
            while (true) {
           
        logger.info("event=scanning_for_delayed_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(10);
        receiveMessageRequest.setVisibilityTimeout(15);
        receiveMessageRequest.setWaitTimeSeconds(1);
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        count += receiveMessageResult.getMessages().size();
       
        if (count >=1000) {
          break;
        }

        if (System.currentTimeMillis() - ts1 > 120*1000) {
          fail("only " + count + " messages found in 120 seconds");
        }
            }

            ts1 = System.currentTimeMillis();
            count = 0;
           
            while (true) {
               
        logger.info("event=scanning_for_revisible_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(10);
        receiveMessageRequest.setWaitTimeSeconds(1);
        receiveMessageRequest.setVisibilityTimeout(10);
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        count += receiveMessageResult.getMessages().size();
       
        for (Message msg : receiveMessageResult.getMessages()) {
          ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest(queueUrl, msg.getReceiptHandle(), 23);
          cqs1.changeMessageVisibility(changeMessageVisibilityRequest);
        }
       
        if (count >=1000) {
          break;
        }

        if (System.currentTimeMillis() - ts1 > 120*1000) {
          fail("only " + count + " messages found in 120 seconds");
        }
            }
           
            ts1 = System.currentTimeMillis();
            count = 0;

            while (true) {
               
        logger.info("event=deleting_newly_revisible_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(10);
        receiveMessageRequest.setWaitTimeSeconds(1);
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        count += receiveMessageResult.getMessages().size();
       
        for (Message msg : receiveMessageResult.getMessages()) {
View Full Code Here


      try {

          SendMessageRequest sendMessageRequest = new SendMessageRequest(queueUrl, message);
          cqs1.sendMessage(sendMessageRequest);

          ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(1);
        // use long poll style requests
        receiveMessageRequest.setWaitTimeSeconds(20);
        // set initial vto to 20 sec
        receiveMessageRequest.setVisibilityTimeout(20);
       
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        if (receiveMessageResult.getMessages().size() == 1) {
         
View Full Code Here

           
            for (int i=0; i<30; i++) {
           
        logger.info("event=scanning_for_delayed_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(10);
        receiveMessageRequest.setVisibilityTimeout(15);
        receiveMessageRequest.setWaitTimeSeconds(1);
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        count += receiveMessageResult.getMessages().size();
       
        for (Message msg : receiveMessageResult.getMessages()) {
View Full Code Here

           
            while (true) {
           
        logger.info("event=scanning_for_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(10);
        if (first) {
          first = false;
          receiveMessageRequest.setVisibilityTimeout(20);
        } else {
          receiveMessageRequest.setVisibilityTimeout(120);
        }
        receiveMessageRequest.setWaitTimeSeconds(1);
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        count += receiveMessageResult.getMessages().size();
       
        if (count >= 1000) {
          break;
        }
       
        if (System.currentTimeMillis() - ts1 > 120*1000) {
          fail("only " + count + " messages found in 120 seconds");
        }
            }
           
            count = 0;
            ts1 = System.currentTimeMillis();
           
            for (int i=0; i<30; i++) {
               
        logger.info("event=scanning_for_delayed_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(10);
        receiveMessageRequest.setVisibilityTimeout(15);
        receiveMessageRequest.setWaitTimeSeconds(1);
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        count += receiveMessageResult.getMessages().size();
       
        for (Message msg : receiveMessageResult.getMessages()) {
View Full Code Here

           
            while (true) {
           
        logger.info("checking for messages");

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(1);
        //receiveMessageRequest.setWaitTimeSeconds(20);
       
        ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);

        if (receiveMessageResult.getMessages().size() == 1) {
View Full Code Here

      }
    } else if (parameters.containsKey("Receive")) {
     
      try {
     
        ReceiveMessageResult result = sqs.receiveMessage(new ReceiveMessageRequest(queueUrl));
        logger.debug("event=receive_message queue_url= " + queueUrl + " user_id=" + userId);
        List<Message> receivedMessages=null;
       
        if (result!=null){
          receivedMessages=result.getMessages();
View Full Code Here

    @Override
    public QSTaskModel getAvailableTask() {
        QSTaskModel task = null;
        while (task == null) {
            ReceiveMessageResult result = sqs.receiveMessage(new ReceiveMessageRequest(queueUrl).withMaxNumberOfMessages(1));
            assert result.getMessages().size() <= 1;

            if (result.getMessages().size() == 1) {
                Message message = result.getMessages().get(0);
View Full Code Here

        : receiveMessageWaitTimeout);
    destroyWaitTime = timeoutSeconds;
    try {
      if (queue == null) {
        if (prefetchQueue.isEmpty()) {
          ReceiveMessageRequest request = new ReceiveMessageRequest(
              queueUrl).withWaitTimeSeconds(timeoutSeconds)
              .withMaxNumberOfMessages(prefetchCount)
              .withAttributeNames("All");

          ReceiveMessageResult result = sqsClient
View Full Code Here

  @Override
  public String pull() {
    String task = "[]";
    if (!StringUtils.isBlank(url)) {
      try {
        ReceiveMessageRequest receiveReq = new ReceiveMessageRequest(url);
        receiveReq.setMaxNumberOfMessages(MAX_MESSAGES);
        List<Message> list = client().receiveMessage(receiveReq).getMessages();

        if (list != null && !list.isEmpty()) {
          Message message = list.get(0);
          client().deleteMessage(new DeleteMessageRequest(url, message.getReceiptHandle()));
View Full Code Here

    }

    /** Poll the SQS queue to see if we've received a message about the job completion yet. **/
    public void waitForJobToComplete(String jobId) {
        while (true) {
            List<Message> messages = sqs.receiveMessage(new ReceiveMessageRequest(queueUrl)).getMessages();
            for (Message message : messages) {
                String messageBody = message.getBody();
                if (!messageBody.startsWith("{")) {
                    messageBody = new String(BinaryUtils.fromBase64(messageBody));
                }
View Full Code Here

TOP

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

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.