kafka-consumer-api

Kafka bootstrap-servers vs zookeeper in kafka-console-consumer

眉间皱痕 提交于 2019-11-28 21:36:33
I'm trying to test run a single Kafka node with 3 brokers & zookeeper. I wish to test using the console tools. I run the producer as such: kafka-console-producer --broker-list localhost:9092,localhost:9093,localhost:9094 --topic testTopic Then I run the consumer as such: kafka-console-consumer --zookeeper localhost:2181 --topic testTopic --from-beginning And I can enter messages in the producer and see them in the consumer, as expected. However , when I run the updated version of the consumer using bootstrap-server, I get nothing. E.g kafka-console-consumer --bootstrap-server localhost:9092

Kafka Consumer Rebalancing Algorithm

余生长醉 提交于 2019-11-28 17:10:25
问题 Can someone please tell me what the rebalancing algorithm is for Kafka consumers? I would like to understand how partition count and consumer threads affect this. Thank you, 回答1: Ok so there are 2 rebalancing algorithms at the moment - Range and RoundRobin . They are also called Partition Assignment Strategies. For the simplicity assume we have a topic T1 with 10 partitions and we also have 2 consumers with different configurations (for the example to be clearer) - C1 with num.streams set to

How does consumer rebalancing work in Kafka?

荒凉一梦 提交于 2019-11-28 16:32:50
When a new consumer/brorker is added or goes down, Kafka triggers a rebalance operation. Is Kafka Rebalancing a blocking operation. Are Kafka consumers blocked while a rebalancing operation is in progress? Depends on what you mean by "blocked". If you mean "are existing connections closed when rebalance is triggered" then the answer is yes. The current Kafka's rebalancing algorithm is unfortunately imperfect. Here is what is happening during consumer rebalance. Assume we have a topic with 10 partitions (0-9), and one consumer (lets name it consumer1 ) consuming it. When a second consumer

Kafka: Consumer API vs Streams API

非 Y 不嫁゛ 提交于 2019-11-28 15:42:43
I recently started learning Kafka and end up with these questions. What is the difference between Consumer and Stream? For me, if any tool/application consume messages from Kafka is a consumer in the Kafka world. How Stream is different as this also consumes from or produce messages to Kafka? and why is it needed as we can write our own consumer application using Consumer API and process them as needed or send them to Spark from the consumer application? I did Google on this, but did not get any good answers for this. Sorry if this question is too trivial. Update April 09, 2018 : Nowadays you

Updating static source based on Kafka Stream using Spark Streaming?

こ雲淡風輕ζ 提交于 2019-11-28 12:17:50
问题 I am using spark-sql 2.4.1v with java8. I have a scenario where I have some meta data in dataset1 i.e. which is loaded from an HDFS Parquet file. And I have another dataset2 which is read from a Kafka Stream. For each record from dataset2 for column1 I need to check columnX in dataset2 if its there in dataset1. If it is there in dataset1,then I need replace the columnX value with column1 value of dataset1 Else I need to add increment (max(column1 ) from dataset1 ) by one and store it dataset1

How to create Custom serializer in kafka?

江枫思渺然 提交于 2019-11-28 11:24:13
There is only few serializer available like, org.apache.kafka.common.serialization.StringSerializer org.apache.kafka.common.serialization.StringSerializer How can we create our own custom serializer ? Here you have an example to use your own serializer/deserializer for the Kafka message value. For Kafka message key is the same thing. We want to send a serialized version of MyMessage as Kafka value and deserialize it again into a MyMessage object at consumer side. Serializing MyMessage in producer side. You should create a serializer class that implements org.apache.kafka.common.serialization

How to write a file to Kafka Producer

99封情书 提交于 2019-11-28 04:31:54
I am trying to load a simple text file instead of standard input in Kafka. After downloading Kafka, I performed the following steps: Started zookeeper: bin/zookeeper-server-start.sh config/zookeeper.properties Started Server bin/kafka-server-start.sh config/server.properties Created a topic named "test": bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test Ran the Producer: bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test Test1 Test2 Listened by the Consumer: bin/kafka-console-consumer.sh --zookeeper localhost:2181 -

Kafka10.1 heartbeat.interval.ms, session.timeout.ms and max.poll.interval.ms

时光怂恿深爱的人放手 提交于 2019-11-28 04:24:52
I am using kafka 0.10.1.1 and confused with the following 3 properties. heartbeat.interval.ms session.timeout.ms max.poll.interval.ms heartbeat.interval.ms - This was added in 0.10.1 and it will send heartbeat between polls. session.timeout.ms - This is to start rebalancing if no request to kafka and it gets reset on every poll. max.poll.interval.ms - This is across the poll. But, when does kafka starts rebalancing? Why do we need these 3? What are the default values for all of them? Thanks Assuming we are talking about Kafka 0.10.1.0 or upwards where each consumer instance employs two threads

How does kafka consumer auto commit work?

让人想犯罪 __ 提交于 2019-11-28 02:57:41
问题 I am reading this one: Automatic Commit The easiest way to commit offsets is to allow the consumer to do it for you. If you configure enable.auto.commit=true, then every five seconds the consumer will commit the largest offset your client received from poll(). The five-second interval is the default and is controlled by setting auto.commit.interval.ms. Just like everything else in the consumer, the automatic commits are driven by the poll loop. Whenever you poll, the consumer checks if it is

Kafka producer TimeoutException: Expiring 1 record(s)

痞子三分冷 提交于 2019-11-28 02:42:35
问题 I am using Kafka with Spring-boot: Kafka Producer class : @Service public class MyKafkaProducer { @Autowired private KafkaTemplate<String, String> kafkaTemplate; private static Logger LOGGER = LoggerFactory.getLogger(NotificationDispatcherSender.class); // Send Message public void sendMessage(String topicName, String message) throws Exception { LOGGER.debug("========topic Name===== " + topicName + "=========message=======" + message); ListenableFuture<SendResult<String, String>> result =