Package com.amazonaws.services.sqs.model

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


        : 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 = sqs.receiveMessage(receiveReq).getMessages();

        if (list != null && !list.isEmpty()) {
          Message message = list.get(0);
          sqs.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

         * */
        public void run() {
           
            try {
                visibilityDeadlineNano = System.nanoTime() + visibilityTimeoutNanos;
                ReceiveMessageRequest request = new ReceiveMessageRequest(qUrl).withMaxNumberOfMessages(config.getMaxBatchSize());
                ResultConverter.appendUserAgent(request, AmazonSQSBufferedAsyncClient.USER_AGENT);
               
                if ( config.getVisibilityTimeoutSeconds() > 0 ) {
                    request.setVisibilityTimeout(config.getVisibilityTimeoutSeconds());
                    visibilityDeadlineNano = System.nanoTime() + TimeUnit.NANOSECONDS.convert(config.getVisibilityTimeoutSeconds(), TimeUnit.SECONDS);
                }
               
                if ( config.isLongPoll() ) {
                    request.withWaitTimeSeconds(config.getLongPollWaitTimeoutSeconds());
                }

                messages = sqsClient.receiveMessage(request).getMessages();
            } catch (AmazonClientException e) {
                exception = e;
View Full Code Here

         * */
        public void run() {
           
            try {
                visibilityDeadlineNano = System.nanoTime() + visibilityTimeoutNanos;
                ReceiveMessageRequest request = new ReceiveMessageRequest(qUrl).withMaxNumberOfMessages(config.getMaxBatchSize());
                ResultConverter.appendUserAgent(request, AmazonSQSBufferedAsyncClient.USER_AGENT);
               
                if ( config.getVisibilityTimeoutSeconds() > 0 ) {
                    request.setVisibilityTimeout(config.getVisibilityTimeoutSeconds());
                    visibilityDeadlineNano = System.nanoTime() + TimeUnit.NANOSECONDS.convert(config.getVisibilityTimeoutSeconds(), TimeUnit.SECONDS);
                }
               
                if ( config.isLongPoll() ) {
                    request.withWaitTimeSeconds(config.getLongPollWaitTimeoutSeconds());
                }

                messages = sqsClient.receiveMessage(request).getMessages();
            } catch (AmazonClientException e) {
                exception = e;
View Full Code Here

    protected int poll() throws Exception {
        // must reset for each poll
        shutdownRunningTask = null;
        pendingExchanges = 0;
       
        ReceiveMessageRequest request = new ReceiveMessageRequest(getQueueUrl());
        request.setMaxNumberOfMessages(getMaxMessagesPerPoll() > 0 ? getMaxMessagesPerPoll() : null);
        request.setVisibilityTimeout(getConfiguration().getVisibilityTimeout() != null ? getConfiguration().getVisibilityTimeout() : null);
        request.setAttributeNames(getConfiguration().getAttributeNames() != null ? getConfiguration().getAttributeNames() : null);
        request.setWaitTimeSeconds(getConfiguration().getWaitTimeSeconds() != null ? getConfiguration().getWaitTimeSeconds() : null);

        LOG.trace("Receiving messages with request [{}]...", request);
       
        ReceiveMessageResult messageResult = getClient().receiveMessage(request);
View Full Code Here

          messages = CQSAPI.receiveMessages(cnsInternal.getUserId(), relativeQueueUrl, maxNumberOfMessages, null);
         
        } else {
       
          String absoluteQueueUrl = Util.getAbsoluteQueueUrlForRelativeUrl(relativeQueueUrl);
          ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(absoluteQueueUrl);
          receiveMessageRequest.setMaxNumberOfMessages(maxNumberOfMessages);
          //receiveMessageRequest.setVisibilityTimeout(CMBProperties.getInstance().getCNSPublishJobVisibilityTimeout());
         
          if (waitTimeSeconds > 0) {
            receiveMessageRequest.setWaitTimeSeconds(waitTimeSeconds);
          }
         
          ReceiveMessageResult receiveMessageResult = sqs.receiveMessage(receiveMessageRequest);
          List<Message> msgs = receiveMessageResult.getMessages();
         
View Full Code Here

        counter = 0;
        long totalCount = 0;
       
        do {
       
          ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
          receiveMessageRequest.setQueueUrl(queueUrl);
          receiveMessageRequest.setMaxNumberOfMessages(10);
         
          ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);
          counter = receiveMessageResult.getMessages().size();
          totalCount += counter;
         
View Full Code Here

     
      if (subscriptionArn.equals("pending confirmation")) {
       
        Thread.sleep(500);
       
        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
        receiveMessageRequest.setQueueUrl(queueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(1);
        ReceiveMessageResult receiveMessageResult = sqs.receiveMessage(receiveMessageRequest);
       
        List<Message> messages = receiveMessageResult.getMessages();
       
        if (messages != null && messages.size() == 1) {
         
            JSONObject o = new JSONObject(messages.get(0).getBody());
           
            if (!o.has("SubscribeURL")) {
              throw new Exception("message is not a confirmation messsage");
            }
           
            String subscriptionUrl = o.getString("SubscribeURL");
            httpGet(subscriptionUrl);
           
            DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest();
            deleteMessageRequest.setReceiptHandle(messages.get(0).getReceiptHandle());
            deleteMessageRequest.setQueueUrl(queueUrl);
            sqs.deleteMessage(deleteMessageRequest);
       
        } else {
          throw new Exception("no confirmation message found");
        }
      }
     
      // publish and receive message
     
      PublishRequest publishRequest = new PublishRequest();
      String messageText = "quamvis sint sub aqua, sub aqua maledicere temptant";
      publishRequest.setMessage(messageText);
      publishRequest.setSubject("unit test message");
      publishRequest.setTopicArn(topicArn);
      sns.publish(publishRequest);
     
      Thread.sleep(500);

      ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
      receiveMessageRequest.setQueueUrl(queueUrl);
      receiveMessageRequest.setMaxNumberOfMessages(1);
      ReceiveMessageResult receiveMessageResult = sqs.receiveMessage(receiveMessageRequest);
     
      List<Message> messages = receiveMessageResult.getMessages();
     
      if (messages != null && messages.size() == 1) {
View Full Code Here

      String resp = CNSTestingUtils.sendHttpMessage(lastMessageUrl, "");

      assertTrue("Expected message '" + message + "', instead found " + resp, resp.contains(message));

      ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
      receiveMessageRequest.setQueueUrl(queueUrl);
      ReceiveMessageResult result = cqs1.receiveMessage(receiveMessageRequest);
     
      assertTrue("No message found", result.getMessages().size() > 0);
      String msg = result.getMessages().get(0).getBody();
      assertTrue("Expected message '" + message + "', instead found " + msg, msg.contains(message));
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.