Package com.amazonaws.services.sqs.model

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


        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 = null;
        try {
            messageResult = getClient().receiveMessage(request);
        } catch (QueueDoesNotExistException e) {
            LOG.info("Queue does not exist....recreating now...");
            reConnectToQueue();
            messageResult = getClient().receiveMessage(request);
        }

        if (LOG.isTraceEnabled()) {
            LOG.trace("Received {} messages", messageResult.getMessages().size());
        }
       
        Queue<Exchange> exchanges = createExchanges(messageResult.getMessages());
        return processBatch(CastUtils.cast(exchanges));
    }
View Full Code Here


        request.setMessageAttributeNames(getConfiguration().getMessageAttributeNames() != null ? getConfiguration().getMessageAttributeNames() : null);
        request.setWaitTimeSeconds(getConfiguration().getWaitTimeSeconds() != null ? getConfiguration().getWaitTimeSeconds() : null);

        LOG.trace("Receiving messages with request [{}]...", request);
       
        ReceiveMessageResult messageResult = null;
        try {
            messageResult = getClient().receiveMessage(request);
        } catch (QueueDoesNotExistException e) {
            LOG.info("Queue does not exist....recreating now...");
            reConnectToQueue();
            messageResult = getClient().receiveMessage(request);
        }

        if (LOG.isTraceEnabled()) {
            LOG.trace("Received {} messages", messageResult.getMessages().size());
        }
       
        Queue<Exchange> exchanges = createExchanges(messageResult.getMessages());
        return processBatch(CastUtils.cast(exchanges));
    }
View Full Code Here

    }

    @Override
    public ReceiveMessageResult receiveMessage(ReceiveMessageRequest receiveMessageRequest) throws AmazonServiceException, AmazonClientException {
        Integer maxNumberOfMessages = receiveMessageRequest.getMaxNumberOfMessages() != null ? receiveMessageRequest.getMaxNumberOfMessages() : Integer.MAX_VALUE;
        ReceiveMessageResult result = new ReceiveMessageResult();
        Collection<Message> resultMessages = new ArrayList<Message>();
       
        synchronized (messages) {
            int fetchSize = 0;
            for (Iterator<Message> iterator = messages.iterator(); iterator.hasNext() && fetchSize < maxNumberOfMessages; fetchSize++) {
                Message rc = iterator.next();
                resultMessages.add(rc);
                iterator.remove();
                scheduleCancelInflight(receiveMessageRequest.getQueueUrl(), rc);
            }
        }
       
        result.setMessages(resultMessages);
        return result;
    }
View Full Code Here

        request.setVisibilityTimeout(getConfiguration().getVisibilityTimeout() != null ? getConfiguration().getVisibilityTimeout() : null);
        request.setAttributeNames(getConfiguration().getAttributeNames() != null ? getConfiguration().getAttributeNames() : null);
       
        LOG.trace("Receiving messages with request [{}]...", request);
       
        ReceiveMessageResult messageResult = getClient().receiveMessage(request);
       
        LOG.trace("Received {} messages", messageResult.getMessages().size());
       
        Queue<Exchange> exchanges = createExchanges(messageResult.getMessages());
        return processBatch(CastUtils.cast(exchanges));
    }
View Full Code Here

            }

            // ReceiveMessage
            else if (request.getOriginalRequest() instanceof ReceiveMessageRequest
                    && response instanceof ReceiveMessageResult) {
                ReceiveMessageResult receiveMessageResult = (ReceiveMessageResult)response;
                receiveMessageResultMd5Check(receiveMessageResult);
            }

            // SendMessageBatch
            else if (request.getOriginalRequest() instanceof SendMessageBatchRequest
View Full Code Here

     *
     * this method assumes that you are holding the finished tasks lock
     * locks when invoking it.  violate this assumption at
     * your own peril */
    private void fillFuture( ReceiveMessageFuture f ){
        ReceiveMessageResult r = new ReceiveMessageResult();
        LinkedList<Message> messages = new LinkedList<Message>();
        r.setMessages(messages);
        Exception exception = null;

        if ( !finishedTasks.isEmpty() ) {
            ReceiveMessageBatchTask t = finishedTasks.getFirst();

            exception = t.getException();
            int retrieved = 0;
            boolean batchDone = false;
            while retrieved < f.getRequestedSize() )
            {
                Message m = t.removeMessage();
                // a non-empty batch can still give back a null
                // message if the message expired.
                if ( null != m) {
                    messages.add(m);
                    ++retrieved;
                }
                else {
                    batchDone = true;
                    break;
                }

            }
            //we may have just drained the batch.
            batchDone = batchDone || t.isEmpty() || ( exception != null );
            if ( batchDone) {
                finishedTasks.removeFirst();
            }
            r.setMessages(messages);
        }

        //if after the above runs the exception is not null,
        //the finished batch has encountered an error, and we will
        //report that in the Future.  Otherwise, we will fill
View Full Code Here

    }

    @Override
    public ReceiveMessageResult receiveMessage(ReceiveMessageRequest receiveMessageRequest) throws AmazonServiceException, AmazonClientException {
        Integer maxNumberOfMessages = receiveMessageRequest.getMaxNumberOfMessages() != null ? receiveMessageRequest.getMaxNumberOfMessages() : Integer.MAX_VALUE;
        ReceiveMessageResult result = new ReceiveMessageResult();
        Collection<Message> resultMessages = new ArrayList<Message>();
       
        synchronized (messages) {
            int fetchSize = 0;
            for (Iterator<Message> iterator = messages.iterator(); iterator.hasNext() && fetchSize < maxNumberOfMessages; fetchSize++) {
                resultMessages.add(iterator.next());
                iterator.remove();
            }
        }
       
        result.setMessages(resultMessages);
        return result;
    }
View Full Code Here

     *
     * this method assumes that you are holding the finished tasks lock
     * locks when invoking it.  violate this assumption at
     * your own peril */
    private void fillFuture( ReceiveMessageFuture f ){
        ReceiveMessageResult r = new ReceiveMessageResult();
        LinkedList<Message> messages = new LinkedList<Message>();
        r.setMessages(messages);
        Exception exception = null;
       
        if ( !finishedTasks.isEmpty() ) {
            ReceiveMessageBatchTask t = finishedTasks.getFirst();
           
            exception = t.getException();
            int retrieved = 0;
           
            boolean batchDone = false;
            while retrieved < f.getRequestedSize() ) 
            {
                Message m = t.removeMessage();
               
                // a non-empty batch can still give back a null
                // message if the message expired.
                if ( null != m) {
                    messages.add(m);
                    ++retrieved;
                }
                else {
                    batchDone = true;
                    break;
                }
               
            }
           
            //we may have just drained the batch.
            batchDone = batchDone || t.isEmpty() || ( exception != null );
           
            if ( batchDone) {
                finishedTasks.removeFirst();
            }
            r.setMessages(messages);
        }
       
        //if after the above runs the exception is not null,
        //the finished batch has encountered an error, and we will
        //report that in the Future.  Otherwise, we will fill
View Full Code Here

          ReceiveMessageRequest request = new ReceiveMessageRequest(
              queueUrl).withWaitTimeSeconds(timeoutSeconds)
              .withMaxNumberOfMessages(prefetchCount)
              .withAttributeNames("All");

          ReceiveMessageResult result = sqsClient
              .receiveMessage(request);
          for (com.amazonaws.services.sqs.model.Message sqsMessage : result
              .getMessages()) {
            prefetchQueue.offer(sqsMessage);
          }
          qMessage = prefetchQueue.poll();
        } else {
View Full Code Here

        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);
       
        LOG.trace("Received {} messages", messageResult.getMessages().size());
       
        Queue<Exchange> exchanges = createExchanges(messageResult.getMessages());
        return processBatch(CastUtils.cast(exchanges));
    }
View Full Code Here

TOP

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

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.