org.apache.kafka.clients.consumer.internals.NoOpConsumerRebalanceListener Java Examples
The following examples show how to use
org.apache.kafka.clients.consumer.internals.NoOpConsumerRebalanceListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CaseController.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void run() { Properties consumerProperties = new Properties(); consumerProperties.put("bootstrap.servers", bootstrapServers); consumerProperties.put("group.id", "testGroup2"); consumerProperties.put("enable.auto.commit", "true"); consumerProperties.put("auto.commit.interval.ms", "1000"); consumerProperties.put("auto.offset.reset", "earliest"); consumerProperties.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); consumerProperties.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); KafkaConsumer<String, String> consumer = new KafkaConsumer<>(consumerProperties); consumer.subscribe(topicPattern, new NoOpConsumerRebalanceListener()); int i = 0; while (i++ <= 10) { try { Thread.sleep(1 * 1000); } catch (InterruptedException e) { } ConsumerRecords<String, String> records = consumer.poll(100); if (!records.isEmpty()) { for (ConsumerRecord<String, String> record : records) { logger.info("header: {}", new String(record.headers() .headers("TEST") .iterator() .next() .value())); logger.info("offset = {}, key = {}, value = {}", record.offset(), record.key(), record.value()); } break; } } consumer.close(); }
Example #2
Source File: LiKafkaConsumerImpl.java From li-apache-kafka-clients with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void subscribe(Collection<String> topics) { subscribe(topics, new NoOpConsumerRebalanceListener()); }
Example #3
Source File: Kafka09ConsumerClient.java From incubator-gobblin with Apache License 2.0 | 2 votes |
/** * Subscribe to a kafka topic * TODO Add multi topic support * @param topic */ @Override public void subscribe(String topic) { this.consumer.subscribe(Lists.newArrayList(topic), new NoOpConsumerRebalanceListener()); }