/** * Main application-side API: wait for the next message delivery and return it. * @param timeout timeout in millisecond * @return the next message or null if timed out * @throws InterruptedException if an interrupt is received while waiting * @throws ShutdownSignalException if the connection is shut down while waiting */ @Nullable public Message nextMessage(long timeout) throws InterruptedException, ShutdownSignalException { if (logger.isTraceEnabled()) { logger.trace("Retrieving delivery for " + this); } checkShutdown(); if (this.missingQueues.size() > 0) { checkMissingQueues(); } Message message = handle(this.queue.poll(timeout, TimeUnit.MILLISECONDS)); if (message == null && this.cancelled.get()) { throw new ConsumerCancelledException(); } return message; }
/** * Main application-side API: wait for the next message delivery and return it. * @param timeout timeout in millisecond * @return the next message or null if timed out * @throws InterruptedException if an interrupt is received while waiting * @throws ShutdownSignalException if the connection is shut down while waiting */ @Nullable public Message nextMessage(long timeout) throws InterruptedException, ShutdownSignalException { if (logger.isTraceEnabled()) { logger.trace("Retrieving delivery for " + this); } checkShutdown(); if (this.missingQueues.size() > 0) { checkMissingQueues(); } Message message = handle(this.queue.poll(timeout, TimeUnit.MILLISECONDS)); if (message == null && this.cancelled.get()) { throw new ConsumerCancelledException(); } return message; }