org.apache.kafka.clients.consumer.Consumer.close()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(289)

本文整理了Java中org.apache.kafka.clients.consumer.Consumer.close()方法的一些代码示例,展示了Consumer.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Consumer.close()方法的具体详情如下:
包路径:org.apache.kafka.clients.consumer.Consumer
类名称:Consumer
方法名:close

Consumer.close介绍

暂无

代码示例

代码示例来源:origin: openzipkin/brave

@Override public void close() {
 delegate.close();
}

代码示例来源:origin: apache/incubator-gobblin

@Override
public void close() throws IOException {
 this.consumer.close();
}

代码示例来源:origin: linkedin/cruise-control

@Override
 public void close() throws Exception {
  _metricConsumer.close();
 }
}

代码示例来源:origin: apache/storm

@Override
public void close() {
  this.consumer.close();
  LOG.debug("Closed");
}

代码示例来源:origin: openzipkin/brave

@Override public void close(long timeout, TimeUnit unit) {
 delegate.close(timeout, unit);
}

代码示例来源:origin: openzipkin/brave

public void close(Duration timeout) {
 delegate.close(timeout);
}

代码示例来源:origin: apache/storm

public void close() {
  consumer.close();
  LOG.debug("Closed");
}

代码示例来源:origin: apache/storm

private void shutdown() {
  try {
    commitIfNecessary();
  } finally {
    //remove resources
    consumer.close();
  }
}

代码示例来源:origin: apache/kylin

@Override
public void close() throws IOException {
  log.info("{} num. processed messages {} ", topic + ":" + split.getBrokers() + ":" + partition,
      numProcessedMessages);
  consumer.close();
}

代码示例来源:origin: confluentinc/ksql

public void close() {
  commandConsumer.wakeup();
  commandConsumer.close();
  commandProducer.close();
 }
}

代码示例来源:origin: apache/nifi

private void closeConsumer(final Consumer<?, ?> consumer) {
  consumerClosedCountRef.incrementAndGet();
  try {
    consumer.unsubscribe();
  } catch (Exception e) {
    logger.warn("Failed while unsubscribing " + consumer, e);
  }
  try {
    consumer.close();
  } catch (Exception e) {
    logger.warn("Failed while closing " + consumer, e);
  }
}

代码示例来源:origin: apache/nifi

private void closeConsumer(final Consumer<?, ?> consumer) {
  consumerClosedCountRef.incrementAndGet();
  try {
    consumer.unsubscribe();
  } catch (Exception e) {
    logger.warn("Failed while unsubscribing " + consumer, e);
  }
  try {
    consumer.close();
  } catch (Exception e) {
    logger.warn("Failed while closing " + consumer, e);
  }
}

代码示例来源:origin: apache/nifi

private void closeConsumer(final Consumer<?, ?> consumer) {
  consumerClosedCountRef.incrementAndGet();
  try {
    consumer.unsubscribe();
  } catch (Exception e) {
    logger.warn("Failed while unsubscribing " + consumer, e);
  }
  try {
    consumer.close();
  } catch (Exception e) {
    logger.warn("Failed while closing " + consumer, e);
  }
}

代码示例来源:origin: apache/nifi

private void closeConsumer(final Consumer<?, ?> consumer) {
  consumerClosedCountRef.incrementAndGet();
  try {
    consumer.unsubscribe();
  } catch (Exception e) {
    logger.warn("Failed while unsubscribing " + consumer, e);
  }
  try {
    consumer.close();
  } catch (Exception e) {
    logger.warn("Failed while closing " + consumer, e);
  }
}

代码示例来源:origin: apache/nifi

private void closeConsumer(final Consumer<?, ?> consumer) {
  consumerClosedCountRef.incrementAndGet();
  try {
    consumer.unsubscribe();
  } catch (Exception e) {
    logger.warn("Failed while unsubscribing " + consumer, e);
  }
  try {
    consumer.close();
  } catch (Exception e) {
    logger.warn("Failed while closing " + consumer, e);
  }
}

代码示例来源:origin: azkaban/azkaban

} finally {
 this.consumer.close();
 log.info("kafka consumer closed...");

代码示例来源:origin: confluentinc/ksql

@Test
public void shouldCloseAllResources() {
 // When:
 commandTopic.close();
 //Then:
 final InOrder ordered = inOrder(commandConsumer);
 ordered.verify(commandConsumer).wakeup();
 ordered.verify(commandConsumer).close();
 verify(commandProducer).close();
}

代码示例来源:origin: spring-projects/spring-kafka

@AfterClass
public static void tearDown() {
  consumer.close();
}

代码示例来源:origin: spring-projects/spring-kafka

@After
public void teardown() {
  if (this.objectOutputTopicConsumer != null) {
    this.objectOutputTopicConsumer.close();
  }
}

代码示例来源:origin: spring-projects/spring-kafka

@Test
public void testReplyingListenerWithErrorHandler() throws Exception {
  Map<String, Object> consumerProps = new HashMap<>(this.consumerFactory.getConfigurationProperties());
  consumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, "testErrorHandlerReplying");
  ConsumerFactory<Integer, String> cf = new DefaultKafkaConsumerFactory<>(consumerProps);
  Consumer<Integer, String> consumer = cf.createConsumer();
  embeddedKafka.consumeFromAnEmbeddedTopic(consumer, "annotated23reply");
  template.send("annotated23", 0, "FoO");
  template.flush();
  ConsumerRecord<Integer, String> reply = KafkaTestUtils.getSingleRecord(consumer, "annotated23reply");
  assertThat(reply.value()).isEqualTo("foo");
  consumer.close();
}

相关文章