Package com.amazonaws.services.sqs.model

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


           
            // receive messages
           
            logger.info("Receiving messages from " + queueUrl);
           
            ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);

            List<Message> messages = new ArrayList<Message>();
            receiveMessageRequest.setMaxNumberOfMessages(10);
            messages = cqs1.receiveMessage(receiveMessageRequest).getMessages();

            assertTrue("Expected 5 messages, received " + messages.size(), messages.size() == 5);

            // change message visibility batch to 10 sec for all messages

            int i = 0;
           
            ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest = new ChangeMessageVisibilityBatchRequest();
            changeMessageVisibilityBatchRequest.setQueueUrl(queueUrl);
           
            List<ChangeMessageVisibilityBatchRequestEntry> visibilityEntryList = new ArrayList<ChangeMessageVisibilityBatchRequestEntry>();
           
            for (Message message : messages) {
             
                logger.info("  Message");
                logger.info("    MessageId:     " + message.getMessageId());
                logger.info("    ReceiptHandle: " + message.getReceiptHandle());
                logger.info("    MD5OfBody:     " + message.getMD5OfBody());
                logger.info("    Body:          " + message.getBody());
               
                for (Entry<String, String> entry : message.getAttributes().entrySet()) {
                    logger.info("  Attribute");
                    logger.info("    Name:  " + entry.getKey());
                    logger.info("    Value: " + entry.getValue());
                }
               
                i++;
               
                ChangeMessageVisibilityBatchRequestEntry entry = new ChangeMessageVisibilityBatchRequestEntry(i + "", message.getReceiptHandle());
                entry.setVisibilityTimeout(10);
                visibilityEntryList.add(entry);
            }
           
            changeMessageVisibilityBatchRequest.setEntries(visibilityEntryList);
            cqs1.changeMessageVisibilityBatch(changeMessageVisibilityBatchRequest);
           
            // check if messages invisible
           
            messages = new ArrayList<Message>();
            receiveMessageRequest.setMaxNumberOfMessages(10);
            messages = cqs1.receiveMessage(receiveMessageRequest).getMessages();

            assertTrue("Expected 0 messages, received " + messages.size(), messages.size() == 0);
           
            Thread.sleep(11000);

            // check if messages revisible
           
            messages = null;
            receiveMessageRequest.setMaxNumberOfMessages(10);
            receiveMessageRequest.setWaitTimeSeconds(1);
            while (messages == null || messages.size() == 0) {
              logger.info("event=scanning_for_messages");
              messages = cqs1.receiveMessage(receiveMessageRequest).getMessages();
            }
View Full Code Here


       
      long messageCount = 0;
       
        for (String queueUrl : queueUrls) {
       
          ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
          receiveMessageRequest.setQueueUrl(queueUrl);
          receiveMessageRequest.setMaxNumberOfMessages(1);
         
          ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);
          counter = receiveMessageResult.getMessages().size();
         
          logger.info(messageCount + " found message in queue " + queueUrl);
View Full Code Here

     
      String message = text;
           
      cqs1.sendMessage(new SendMessageRequest(queueUrl, message));
     
      ReceiveMessageResult result = cqs1.receiveMessage(new ReceiveMessageRequest(queueUrl));
     
      if (result != null && result.getMessages().size() == 1) {
        assertTrue("wrong message content: " + result.getMessages().get(0).getBody(), message.equals(result.getMessages().get(0).getBody()));
        logger.info("event=message_found queue=" + queueUrl + " message=" + message);
      } else {
View Full Code Here

      //test redis queue count is 0
      assertTrue("wrong message count in Redis: " + redisP.getCacheQueueMessageCount(ralativeUrl), redisP.getCacheQueueMessageCount(ralativeUrl)==0);
      //test if retrieve can get the same number of message and same body of message after cache filler
      Map <String, String> resultMap = new HashMap<String, String>();
      for (int i = 0; i < num; i ++) {
        ReceiveMessageResult result = cqs1.receiveMessage(new ReceiveMessageRequest(queueUrl));
        if (i == 0) {
          try {
          Thread.sleep(num);
          } catch (Exception e) {
            fail("exception while sleep " + e);
View Full Code Here

        logger.info("using small test message");
        message = text;
      }
     
      cqs1.sendMessage(new SendMessageRequest(queueUrl, message.toString()));
      ReceiveMessageResult result = cqs1.receiveMessage(new ReceiveMessageRequest(queueUrl));
     
      attributes.put("IsCompressed", "false");
      cqs1.setQueueAttributes(new SetQueueAttributesRequest(queueUrl,attributes));
     
      if (result != null && result.getMessages().size() == 1) {
View Full Code Here

   */
  private List<String> receiveMessage(String queueUrl) {

    List<String> messageBodies = new ArrayList<String>();
   
    ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();

    receiveMessageRequest.setQueueUrl(queueUrl);
    receiveMessageRequest.setMaxNumberOfMessages(numBatchReceive);

    // use this to test with long poll

    //receiveMessageRequest.setWaitTimeSeconds(1);

View Full Code Here

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

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

          if (receiveMessageResult.getMessages().size() == 1) {
            assertTrue("wrong message content", receiveMessageResult.getMessages().get(0).getBody().equals(message));
View Full Code Here

     
      while (true) {
        try {
          Thread.currentThread().sleep(receiveDelay);
          long start = System.currentTimeMillis();
          ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
          receiveMessageRequest.setQueueUrl(queueUrl);
          receiveMessageRequest.setMaxNumberOfMessages(10);
          receiveMessageRequest.setWaitTimeSeconds(20);
          ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);
          long end = System.currentTimeMillis();
          receiveSuccessCount.incrementAndGet();
          actualMessagesReceivedCount.addAndGet(receiveMessageResult.getMessages().size());
          if (receiveMessageResult.getMessages().size() > 0) {
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

           
            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

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.