Reputation: 459
I have implemented a consumer with the following settings.
allow.auto.create.topics = true
auto.commit.interval.ms = 1000
auto.offset.reset = latest
bootstrap.servers = [confluent-kafka-cp-kafka-headless:9092]
check.crcs = true
client.dns.lookup = default
client.id =
client.rack =
connections.max.idle.ms = 540000
default.api.timeout.ms = 60000
enable.auto.commit = false
exclude.internal.topics = true
fetch.max.bytes = 52428800
fetch.max.wait.ms = 500
fetch.min.bytes = 1
group.id = kafka-consumer
group.instance.id = null
heartbeat.interval.ms = 3000
interceptor.classes = []
internal.leave.group.on.close = true
isolation.level = read_uncommitted
key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
max.partition.fetch.bytes = 1048576
max.poll.interval.ms = 300000
max.poll.records = 200
metadata.max.age.ms = 300000
metric.reporters = []
metrics.num.samples = 2
metrics.recording.level = INFO
metrics.sample.window.ms = 30000
partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
receive.buffer.bytes = 65536
reconnect.backoff.max.ms = 1000
reconnect.backoff.ms = 50
request.timeout.ms = 30000
retry.backoff.ms = 100
sasl.client.callback.handler.class = null
sasl.jaas.config = null
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.min.time.before.relogin = 60000
sasl.kerberos.service.name = null
sasl.kerberos.ticket.renew.jitter = 0.05
sasl.kerberos.ticket.renew.window.factor = 0.8
sasl.login.callback.handler.class = null
sasl.login.class = null
sasl.login.refresh.buffer.seconds = 300
sasl.login.refresh.min.period.seconds = 60
sasl.login.refresh.window.factor = 0.8
sasl.login.refresh.window.jitter = 0.05
sasl.mechanism = GSSAPI
security.protocol = PLAINTEXT
security.providers = null
send.buffer.bytes = 131072
session.timeout.ms = 30000
ssl.cipher.suites = null
ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
ssl.endpoint.identification.algorithm = https
ssl.key.password = null
ssl.keymanager.algorithm = SunX509
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.protocol = TLS
ssl.provider = null
ssl.secure.random.implementation = null
ssl.trustmanager.algorithm = PKIX
ssl.truststore.location = null
ssl.truststore.password = null
ssl.truststore.type = JKS
value.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
In my code I am trying to print the record size after every poll like following -
protected static final int MAX_WAIT = 60;
while (true) {
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMinutes(MAX_WAIT));
sysout(records.count());
}
However I am seeing the record.count = 1. I was expecting it to fetch bunch of records in a single poll() and not a single record.
My event looks like follows -
{"event": {"sensor": "sensorA", "current": 33, "etime": "1588375763429"}}}
My producer is running continuously. I am not sure whether the config settings are correct or whether the producer is not producing enough data for consumer to fetch in one poll.
NOTE - I am new to kafka
Regards, Edi
Upvotes: 0
Views: 1410
Reputation: 178
As previously mentioned, try to increase the fetch.min.bytes
parameter.
Upvotes: 0
Reputation: 4024
Assuming your producer is sending enough records, try to increase the following parameters:
fetch.max.wait.ms = 60000
fetch.min.bytes = 1024000
Now the consumer should wait for higher minimum amount of bytes before fetching records from Kafka.
I will provide further explanation about these changes in case it solves your problem.
Upvotes: 1