public void deadLetter(Long msgId) { try { channel.basicReject(msgId, false); } catch (Exception e) { logger.error("could not fail with dead-lettering (when configured) for msgId: " + msgId, e); reporter.reportError(e); } }
public void failWithRedelivery(Long msgId) { try { channel.basicReject(msgId, true); } catch (Exception e) { logger.error("could not fail with redelivery for msgId: " + msgId, e); reporter.reportError(e); } }
public void ack(Long msgId) { try { channel.basicAck(msgId, false); } catch (Exception e) { logger.error("could not ack for msgId: " + msgId, e); reporter.reportError(e); } }
public Message nextMessage() { reinitIfNecessary(); if (consumerTag == null || consumer == null) return Message.NONE; try { return Message.forDelivery(consumer.nextDelivery(MS_WAIT_FOR_MESSAGE)); } catch (ShutdownSignalException sse) { reset(); logger.error("shutdown signal received while attempting to get next message", sse); reporter.reportError(sse); return Message.NONE; } catch (InterruptedException ie) { /* nothing to do. timed out waiting for message */ logger.debug("interruepted while waiting for message", ie); return Message.NONE; } catch (ConsumerCancelledException cce) { /* if the queue on the broker was deleted or node in the cluster containing the queue failed */ reset(); logger.error("consumer got cancelled while attempting to get next message", cce); reporter.reportError(cce); return Message.NONE; } }
public void open() { try { connection = createConnection(); channel = connection.createChannel(); if (prefetchCount > 0) { logger.info("setting basic.qos / prefetch count to " + prefetchCount + " for " + queueName); channel.basicQos(prefetchCount); } // run any declaration prior to queue consumption declarator.execute(channel); consumer = new QueueingConsumer(channel); consumerTag = channel.basicConsume(queueName, isAutoAcking(), consumer); } catch (Exception e) { reset(); logger.error("could not open listener on queue " + queueName); reporter.reportError(e); } }