List of usage examples for com.rabbitmq.client Channel basicReject
void basicReject(long deliveryTag, boolean requeue) throws IOException;
From source file:com.abiquo.commons.amqp.util.ConsumerUtils.java
License:Open Source License
public static void rejectMessage(Channel channel, long tag) throws IOException { channel.basicReject(tag, false); }
From source file:com.abiquo.commons.amqp.util.ConsumerUtils.java
License:Open Source License
public static void rejectMessageAndRequeue(Channel channel, long tag) throws IOException { channel.basicReject(tag, true); }
From source file:mx.bigdata.utils.amqp.AMQPClientHelperImpl.java
License:Apache License
public void reject(Channel channel, QueueingConsumer.Delivery delivery) throws Exception { long deliveryTag = delivery.getEnvelope().getDeliveryTag(); channel.basicReject(deliveryTag, true); }
From source file:net.lshift.accent.AccentConsumer.java
License:Apache License
/** * Reject a message with the given id.// w w w.ja v a 2s . c om * * @param deliveryTag * @param requeue * @throws StaleMessageException if the message could not be rejected (for example, if the channel had been reset in the meantime). */ public void reliableReject(final long deliveryTag, final boolean requeue) { final Long channelDeliveryTag = outstandingAcks.get(deliveryTag); if (channelDeliveryTag != null) { owner.executeIfChannelValid(new ChannelCallback() { public void runWithChannel(Channel c) throws IOException { c.basicReject(channelDeliveryTag, requeue); outstandingAcks.remove(deliveryTag); } }); } else { throw new StaleMessageException(deliveryTag); } }
From source file:org.graylog2.inputs.amqp.AMQPConsumer.java
License:Open Source License
public Consumer createConsumer(final Channel channel) { return new DefaultConsumer(channel) { @Override//from www .j a va 2 s . c om public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { try { // The duplication here is a bit unfortunate. Improve by having a Processor Interface. switch (queueConfig.getInputType()) { case GELF: GELFMessage gelf = new GELFMessage(body); try { gelfProcessor.messageReceived(gelf); } catch (BufferOutOfCapacityException e) { LOG.warn("ProcessBufferProcessor is out of capacity. Requeuing message!"); channel.basicReject(envelope.getDeliveryTag(), true); reQueuedMessages.mark(); return; } handledGELFMessages.mark(); break; case SYSLOG: try { syslogProcessor.messageReceived(new String(body), connection.getAddress()); } catch (BufferOutOfCapacityException e) { LOG.warn("ProcessBufferProcessor is out of capacity. Requeuing message!"); channel.basicReject(envelope.getDeliveryTag(), true); reQueuedMessages.mark(); return; } handledSyslogMessages.mark(); break; } channel.basicAck(envelope.getDeliveryTag(), false); handledMessages.mark(); } catch (Exception e) { LOG.error("Could not handle message from AMQP.", e); } } }; }
From source file:org.mule.transport.amqp.AmqpMessageRejecter.java
License:Open Source License
public static void reject(final MuleMessage message, final boolean requeue) throws SessionException { final Long deliveryTag = message.getInboundProperty(AmqpConstants.DELIVERY_TAG); if (deliveryTag == null) { LOG.warn("Missing " + AmqpConstants.DELIVERY_TAG + " inbound property, impossible to reject message: " + message);/*from w w w . j a v a 2s.c o m*/ return; } final Channel channel = AmqpConnector.getChannelFromMessage(message); if (channel == null) { throw new SessionException(MessageFactory.createStaticMessage("No " + AmqpConstants.CHANNEL + " session property found, impossible to reject message: " + message)); } try { channel.basicReject(deliveryTag, requeue); } catch (final IOException ioe) { throw new SessionException( MessageFactory.createStaticMessage( "Failed to reject message w/deliveryTag: " + deliveryTag + " on channel: " + channel), ioe); } if (LOG.isDebugEnabled()) { LOG.debug("Manually rejected message w/deliveryTag: " + deliveryTag + " on channel: " + channel); } }
From source file:org.mule.transport.amqp.internal.processor.Rejecter.java
License:Open Source License
public void reject(final MuleMessage message, final boolean requeue) throws MuleException { final Long deliveryTag = getDeliveryTagOrFail(message, CHANNEL_ACTION); final Channel channel = getChannelOrFail(message, CHANNEL_ACTION); try {/*from www . j a v a 2s. c o m*/ channel.basicReject(deliveryTag, requeue); } catch (final Exception e) { throw new DefaultMuleException( "Failed to reject message w/deliveryTag: " + deliveryTag + " on channel: " + channel, e); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Manually rejected message w/deliveryTag: " + deliveryTag + " on channel: " + channel); } }
From source file:org.springframework.amqp.rabbit.connection.RabbitResourceHolder.java
License:Apache License
public void rollbackAll() { for (Channel channel : this.channels) { if (logger.isDebugEnabled()) { logger.debug("Rolling back messages to channel: " + channel); }//from www. j a va 2s . co m RabbitUtils.rollbackIfNecessary(channel); if (deliveryTags.containsKey(channel)) { for (Long deliveryTag : deliveryTags.get(channel)) { try { channel.basicReject(deliveryTag, true); } catch (IOException ex) { throw new AmqpIOException(ex); } } // Need to commit the reject (=nack) RabbitUtils.commitIfNecessary(channel); } } }