Tabnine Logo
Channel.basicReject
Code IndexAdd Tabnine to your IDE (free)

How to use
basicReject
method
in
com.rabbitmq.client.Channel

Best Java code snippets using com.rabbitmq.client.Channel.basicReject (Showing top 20 results out of 315)

origin: apache/nifi

  @Override
  public void handleDelivery(final String consumerTag, final Envelope envelope, final BasicProperties properties, final byte[] body) throws IOException {
    if (!autoAcknowledge && closed) {
      channel.basicReject(envelope.getDeliveryTag(), true);
      return;
    }
    try {
      responseQueue.put(new GetResponse(envelope, properties, body, Integer.MAX_VALUE));
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
};
origin: spring-projects/spring-integration

  break;
case REJECT:
  this.ackInfo.getChannel().basicReject(deliveryTag, false);
  break;
case REQUEUE:
  this.ackInfo.getChannel().basicReject(deliveryTag, true);
  break;
default:
origin: spring-projects/spring-amqp

@Override
public void basicReject(long deliveryTag, boolean requeue)
    throws IOException {
  this.delegate.basicReject(deliveryTag, requeue);
}
origin: org.springframework.amqp/spring-rabbit

@Override
public void basicReject(long deliveryTag, boolean requeue)
    throws IOException {
  this.delegate.basicReject(deliveryTag, requeue);
}
origin: com.github.cafdataprocessing/worker-policy-testing

@Override
public void processReject(long tag)
{
  try {
    channel.basicReject(tag, false);
    // Do NOT count down for messages we are going to reject.
    // latch.countDown();
  } catch (IOException e) {
    e.printStackTrace();
  }
}
origin: spring-projects/spring-integration

private void testNackOrRequeue(boolean requeue) throws IOException, TimeoutException {
  Channel channel = mock(Channel.class);
  willReturn(true).given(channel).isOpen();
  Envelope envelope = new Envelope(123L, false, "ex", "rk");
  BasicProperties props = new BasicProperties.Builder().build();
  GetResponse getResponse = new GetResponse(envelope, props, "bar".getBytes(), 0);
  willReturn(getResponse).given(channel).basicGet("foo", false);
  Connection connection = mock(Connection.class);
  willReturn(true).given(connection).isOpen();
  willReturn(channel).given(connection).createChannel();
  ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
  willReturn(connection).given(connectionFactory).newConnection((ExecutorService) isNull(), anyString());
  CachingConnectionFactory ccf = new CachingConnectionFactory(connectionFactory);
  AmqpMessageSource source = new AmqpMessageSource(ccf, "foo");
  Message<?> received = source.receive();
  verify(connection).createChannel();
  StaticMessageHeaderAccessor.getAcknowledgmentCallback(received)
      .acknowledge(requeue ? Status.REQUEUE : Status.REJECT);
  verify(channel).basicReject(123L, requeue);
  verify(connection).createChannel();
  ccf.destroy();
  verify(channel).close();
  verify(connection).close(30000);
}
origin: org.apache.airavata/airavata-messaging-core

  public void deadLetter(Long msgId) throws Exception {
    try {
      channel.basicReject(msgId, false);
    } catch (ShutdownSignalException sse) {
      reset();
      String msg = "shutdown signal received while attempting to fail with no redelivery";
      log.error(msg, sse);
      throw new Exception(msg, sse);
    } catch (Exception e) {
      String msg = "could not fail with dead-lettering (when configured) for msgId: " + msgId;
      log.error(msg, e);
      throw new Exception(msg, e);
    }
  }
}
origin: org.apache.airavata/airavata-messaging-core

public void failWithRedelivery(Long msgId) throws Exception {
  try {
    channel.basicReject(msgId, true);
  } catch (ShutdownSignalException sse) {
    reset();
    String msg = "shutdown signal received while attempting to fail with redelivery";
    log.error(msg, sse);
    throw new Exception(msg, sse);
  } catch (Exception e) {
    String msg = "could not fail with redelivery for msgId: " + msgId;
    log.error(msg, e);
    throw new Exception(msg, e);
  }
}
origin: rapportive-oss/storm-amqp-spout

/**
 * Tells the AMQP broker to drop (Basic.Reject) the message.
 *
 * <p><strong>N.B.</strong> this does <em>not</em> requeue the message:
 * failed messages will simply be dropped.  This is to prevent infinite
 * redelivery in the event of non-transient failures (e.g. malformed
 * messages).  However it means that messages will <em>not</em> be retried
 * in the event of transient failures.</p>
 *
 * <p><strong>TODO</strong> make this configurable.</p>
 */
@Override
public void fail(Object msgId) {
  if (msgId instanceof Long) {
    final long deliveryTag = (Long) msgId;
    if (amqpChannel != null) {
      try {
        amqpChannel.basicReject(deliveryTag, false /* don't requeue */);
      } catch (IOException e) {
        log.warn("Failed to reject delivery-tag " + deliveryTag, e);
      }
    }
  } else {
    log.warn(String.format("don't know how to reject(%s: %s)", msgId.getClass().getName(), msgId));
  }
}
origin: gmr/rabbitmq-flume-plugin

private void rejectMessage(long deliveryTag) {
  try {
    channel.basicReject(deliveryTag, requeuing);
  } catch (IOException ex) {
    logger.error("Error rejecting message from {}: {}", this, ex);
    counterGroup.incrementAndGet(COUNTER_EXCEPTION);
  }
  counterGroup.incrementAndGet(COUNTER_REJECT);
}
origin: NationalSecurityAgency/lemongrenade

public void deadLetter(Long msgId) {
  reinitIfNecessary();
  try {
    channel.basicReject(msgId, false);
  } catch (ShutdownSignalException sse) {
    reset();
    logger.error("Shutdown signal received while attempting to fail with no redelivery.", sse);
    reporter.reportError(sse);
  } catch (Exception e) {
    logger.error("Could not fail with dead-lettering (when configured) for msgId: " + msgId, e);
    reporter.reportError(e);
  }
}
origin: ppat/storm-rabbitmq

public void failWithRedelivery(Long msgId) {
 reinitIfNecessary();
 try {
  channel.basicReject(msgId, true);
 } catch (ShutdownSignalException sse) {
  reset();
  logger.error("shutdown signal received while attempting to fail with redelivery", sse);
  reporter.reportError(sse);
 } catch (Exception e) {
  logger.error("could not fail with redelivery for msgId: " + msgId, e);
  reporter.reportError(e);
 }
}
origin: NationalSecurityAgency/lemongrenade

public void failWithRedelivery(Long msgId) {
  reinitIfNecessary();
  try {
    channel.basicReject(msgId, true);
  } catch (ShutdownSignalException sse) {
    reset();
    logger.error("Shutdown signal received while attempting to fail with redelivery.", sse);
    reporter.reportError(sse);
  } catch (Exception e) {
    logger.error("Could not fail with redelivery for msgId: " + msgId, e);
    reporter.reportError(e);
  }
}
origin: ppat/storm-rabbitmq

public void deadLetter(Long msgId) {
 reinitIfNecessary();
 try {
  channel.basicReject(msgId, false);
 } catch (ShutdownSignalException sse) {
  reset();
  logger.error("shutdown signal received while attempting to fail with no redelivery", sse);
  reporter.reportError(sse);
 } catch (Exception e) {
  logger.error("could not fail with dead-lettering (when configured) for msgId: " + msgId, e);
  reporter.reportError(e);
 }
}
origin: spring-projects/spring-amqp

public void rollbackAll() {
  for (Channel channel : this.channels) {
    if (logger.isDebugEnabled()) {
      logger.debug("Rolling back messages to channel: " + channel);
    }
    RabbitUtils.rollbackIfNecessary(channel);
    if (this.deliveryTags.containsKey(channel)) {
      for (Long deliveryTag : this.deliveryTags.get(channel)) {
        try {
          channel.basicReject(deliveryTag, this.requeueOnRollback);
        }
        catch (IOException ex) {
          throw new AmqpIOException(ex);
        }
      }
      // Need to commit the reject (=nack)
      RabbitUtils.commitIfNecessary(channel);
    }
  }
}
origin: org.springframework.amqp/spring-rabbit

public void rollbackAll() {
  for (Channel channel : this.channels) {
    if (logger.isDebugEnabled()) {
      logger.debug("Rolling back messages to channel: " + channel);
    }
    RabbitUtils.rollbackIfNecessary(channel);
    if (this.deliveryTags.containsKey(channel)) {
      for (Long deliveryTag : this.deliveryTags.get(channel)) {
        try {
          channel.basicReject(deliveryTag, this.requeueOnRollback);
        }
        catch (IOException ex) {
          throw new AmqpIOException(ex);
        }
      }
      // Need to commit the reject (=nack)
      RabbitUtils.commitIfNecessary(channel);
    }
  }
}
origin: vvsuperman/coolmq

@Override
public void onMessage(Message message, Channel channel) throws Exception {
  MessageProperties messageProperties = message.getMessageProperties();
  Long deliveryTag = messageProperties.getDeliveryTag();
  Long consumerCount = redisTemplate.opsForHash().increment(MQConstants.MQ_CONSUMER_RETRY_COUNT_KEY,
      messageProperties.getMessageId(), 1);
  logger.info("收到消息,当前消息ID:{} 消费次数:{}", messageProperties.getMessageId(), consumerCount);
  try {
    receiveMessage(message);
    // 成功的回执
    channel.basicAck(deliveryTag, false);
    // 如果消费成功,将Redis中统计消息消费次数的缓存删除
    redisTemplate.opsForHash().delete(MQConstants.MQ_CONSUMER_RETRY_COUNT_KEY,
        messageProperties.getMessageId());
  } catch (Exception e) {
    logger.error("RabbitMQ 消息消费失败," + e.getMessage(), e);
    if (consumerCount >= MQConstants.MAX_CONSUMER_COUNT) {
      // 入死信队列
      channel.basicReject(deliveryTag, false);
    } else {
      // 重回到队列,重新消费, 按照2的指数级递增
      Thread.sleep((long) (Math.pow(MQConstants.BASE_NUM, consumerCount)*1000));
      redisTemplate.opsForHash().increment(MQConstants.MQ_CONSUMER_RETRY_COUNT_KEY,
          messageProperties.getMessageId(), 1);
      channel.basicNack(deliveryTag, false, true);
    }
  }
}
origin: org.springframework.integration/spring-integration-amqp

  break;
case REJECT:
  this.ackInfo.getChannel().basicReject(deliveryTag, false);
  break;
case REQUEUE:
  this.ackInfo.getChannel().basicReject(deliveryTag, true);
  break;
default:
origin: baratine/baratine

 @Override
 public void handleDelivery(String consumerTag,
               Envelope envelope,
               AMQP.BasicProperties properties,
               byte[] body)
  throws IOException
 {
  RabbitMessage msg = RabbitMessage.newMessage().body(body)
                         .properties(properties)
                         .redeliver(envelope.isRedeliver());
  long deliveryTag = envelope.getDeliveryTag();
  _self.onRabbitReceive(msg, (Void, e) -> {
   if (e != null) {
    _channel.basicReject(deliveryTag, false);
   }
   else {
    _channel.basicAck(deliveryTag, false);
   }
  });
 }
});
origin: spring-projects/spring-amqp

  rejectLatch.countDown();
  return null;
}).given(channel).basicReject(anyLong(), anyBoolean());
willAnswer(invocation -> {
  rejectLatch.countDown();
  verify(channel).basicReject(anyLong(), eq(expectRequeue));
com.rabbitmq.clientChannelbasicReject

Popular methods of Channel

  • basicPublish
  • queueDeclare
  • close
  • basicConsume
  • basicAck
  • exchangeDeclare
  • queueBind
  • isOpen
  • basicQos
  • basicCancel
  • basicNack
  • basicGet
  • basicNack,
  • basicGet,
  • confirmSelect,
  • queueDeclarePassive,
  • queueDelete,
  • exchangeDeclarePassive,
  • queueUnbind,
  • getConnection,
  • txCommit

Popular in Java

  • Making http requests using okhttp
  • getResourceAsStream (ClassLoader)
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Path (java.nio.file)
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now