Poll SQS queue for incoming messages, filter them, and return a list of SQS Messages.

@return a list of SQS messages.
191068
public List<Message> pollQueue() {
        boolean success = false;
        ProgressStatus pollQueueStatus = new ProgressStatus(ProgressState.pollQueue, new BasicPollQueueInfo(0, success));
        final Object reportObject = progressReporter.reportStart(pollQueueStatus);

        ReceiveMessageRequest request = new ReceiveMessageRequest().withAttributeNames(ALL_ATTRIBUTES);
        request.setQueueUrl(config.getSqsUrl());
        request.setVisibilityTimeout(config.getVisibilityTimeout());
        request.setMaxNumberOfMessages(DEFAULT_SQS_MESSAGE_SIZE_LIMIT);
        request.setWaitTimeSeconds(DEFAULT_WAIT_TIME_SECONDS);

        List<Message> sqsMessages = new ArrayList<Message>();
        try {

            ReceiveMessageResult result = sqsClient.receiveMessage(request);
            sqsMessages = result.getMessages();
            logger.info("Polled " + sqsMessages.size() + " sqs messages from " + config.getSqsUrl());

            success = true;
        } catch (AmazonServiceException e) {
            LibraryUtils.handleException(exceptionHandler, pollQueueStatus, e, "Failed to poll sqs message.");

        } finally {
            LibraryUtils.endToProcess(progressReporter, success, pollQueueStatus, reportObject);
        }
        return sqsMessages;

    }
1045667
private Collection<Message> peekMessages(String shardName, int itemsToPeek) throws MessageQueueException {
        try {
            ColumnList<MessageQueueEntry> result = keyspace.prepareQuery(queueColumnFamily)
                    .setConsistencyLevel(consistencyLevel)
                    .getKey(shardName)
                    .withColumnRange(new RangeBuilder()
                    .setLimit(itemsToPeek)
                    .setStart(entrySerializer
                                .makeEndpoint((byte)MessageQueueEntryType.Message.ordinal(), Equality.GREATER_THAN_EQUALS)
                                .toBytes())
                    .setEnd(entrySerializer
                                .makeEndpoint((byte)MessageQueueEntryType.Message.ordinal(), Equality.LESS_THAN_EQUALS)
                                .toBytes())
                    .build())
                    .execute()
                    .getResult();

            List<Message> messages = Lists.newArrayListWithCapacity(result.size());
            for (Column<MessageQueueEntry> column : result) {
                Message message = extractMessageFromColumn(column);
                if (message != null)
                    messages.add(message);
            }
            return messages;
        } catch (ConnectionException e) {
            throw new MessageQueueException("Error peeking for messages from shard " + shardName, e);
        }
    }
200488
protected CmsMessages getMessages() {

        if (m_messages == null) {
            // initialize the localized messages
            m_messages = new CmsMessages(Messages.get().getBundleName(), getLocale().toString());
        }
        return m_messages;
    }
1129805
private List<String> getProcessList(String queueName) throws RabbitmqCommunicateException
    {
        List<String> processList = getContextBuilder().getProcessList(queueName);
        if (processList == null || processList.size() == 0)
        {
            String messageFmt = "QueueName's ProcessList is not defined. QueueName={0}";
            String message = MessageFormat.format(messageFmt, queueName);
            throw new RabbitmqCommunicateException(message);
        }
        return processList;
    }
856453
def get_messages(self):
        
        if not self._messages:  # if not already cached
            query = self._dbman.query('thread:' + self._id)
            thread = next(query.search_threads())

            def accumulate(acc, msg):
                M = Message(self._dbman, msg, thread=self)
                acc[M] = []
                r = msg.get_replies()
                if r is not None:
                    for m in r:
                        acc[M].append(accumulate(acc, m))
                return M

            self._messages = {}
            for m in thread.get_toplevel_messages():
                self._toplevel_messages.append(accumulate(self._messages, m))
        return self._messages
874256
private CmsMessages getMessages() {

        if (m_messages == null) {
            if (m_cms != null) {
                m_messages = Messages.get().getBundle(OpenCms.getWorkplaceManager().getWorkplaceLocale(m_cms));
            } else {
                m_messages = Messages.get().getBundle();
            }
        }
        return m_messages;
    }
198442
public Task poll() {
        Task result = taskList[activeIndex].poll();
        if (result != null) {
            if (activeIndex == 0)
                result.removeFromQueue0();
            else
                result.removeFromQueue1();
        }

        return result;
    }
16945
public CompletableFuture<Collection<JobStatusMessage>> listJobs() {
		return runDispatcherCommand(dispatcherGateway ->
			dispatcherGateway
				.requestMultipleJobDetails(rpcTimeout)
				.thenApply(jobs ->
					jobs.getJobs().stream()
						.map(details -> new JobStatusMessage(details.getJobId(), details.getJobName(), details.getStatus(), details.getStartTime()))
						.collect(Collectors.toList())));
	}
340328
def list_sqs(region, filter_by_kwargs):
    """"""
    conn = boto.sqs.connect_to_region(region)
    queues = conn.get_all_queues()
    return lookup(queues, filter_by=filter_by_kwargs)
1326886
public static void pushMessages(String queueURL, List<String> messages) {
		if (!StringUtils.isBlank(queueURL) && messages != null) {
			// only allow strings - ie JSON
			try {
				int	j = 0;
				List<SendMessageBatchRequestEntry> msgs = new ArrayList<>(MAX_MESSAGES);
				for (int i = 0; i < messages.size(); i++) {
					String message = messages.get(i);
					if (!StringUtils.isBlank(message)) {
						msgs.add(new SendMessageBatchRequestEntry().
								withMessageBody(message).
								withId(Integer.toString(i)));
					}
					if (++j >= MAX_MESSAGES || i == messages.size() - 1) {
						if (!msgs.isEmpty()) {
							getClient().sendMessageBatch(queueURL, msgs);
							msgs.clear();
						}
						j = 0;
					}
				}
			} catch (AmazonServiceException ase) {
				logException(ase);
			} catch (AmazonClientException ace) {
				logger.error("Could not reach SQS. {}", ace.toString());
			}
		}
	}
1168744
public List<MessageDestinationType<WebAppType<T>>> getAllMessageDestination()
   {
      List<MessageDestinationType<WebAppType<T>>> list = new ArrayList<MessageDestinationType<WebAppType<T>>>();
      List<Node> nodeList = childNode.get("message-destination");
      for(Node node: nodeList)
      {
         MessageDestinationType<WebAppType<T>>  type = new MessageDestinationTypeImpl<WebAppType<T>>(this, "message-destination", childNode, node);
         list.add(type);
      }
      return list;
   }
544370
public Collection<AsteriskQueueMember> getMembers()
    {
        List<AsteriskQueueMember> listOfMembers = new ArrayList<>(members.size());
        synchronized (members)
        {
            listOfMembers.addAll(members.values());
        }
        return listOfMembers;
    }
938840
public SeqnoList getMissing(int max_msgs) {
        lock.lock();
        try {
            if(size == 0)
                return null;
            long start_seqno=getHighestDeliverable() +1;
            int capacity=(int)(hr - start_seqno);
            int max_size=max_msgs > 0? Math.min(max_msgs, capacity) : capacity;
            if(max_size <= 0)
                return null;
            Missing missing=new Missing(start_seqno, max_size);
            long to=max_size > 0? Math.min(start_seqno + max_size-1, hr-1) : hr-1;
            forEach(start_seqno, to, missing);
            return missing.getMissingElements();
        }
        finally {
            lock.unlock();
        }
    }
782795
public Iterator<BaseMessageFilter> getFilterList(BaseMessageHeader messageHeader)
    {
        if (messageHeader == null)
            return super.getFilterList(messageHeader);  // ALL The filters
        return this.getRegistry().getFilterList(messageHeader);
    }
46929
public List getReceivers() {
		ArrayList result = new ArrayList();
		synchronized (attributes) {
			Iterator i = attributes.values().iterator();
			while (i.hasNext()) {
				Object o = i.next();
				if (o instanceof ReceiverQueue) {
					result.add(o);
				}
			}
		}
		return result;
	}
598677
public Iterator<QueueUser> getUsers() {
        if (users == null) {
            return new HashSet<QueueUser>().iterator();
        }
        return Collections.unmodifiableSet(users).iterator();
    }
572423
public List<Item> getQueuedItems() {
        LinkedList<Item> list = new LinkedList<>();
        for (Item item : Jenkins.getInstance().getQueue().getItems()) {
            if (item.task == owner) {
                list.addFirst(item);
            }
        }
    	return list;
    }