具有给定周期的批处理消费者不适用于 Spring Cloud Stream(StreamListener)中的多个分区?
Batch Consumer with a given period doesn't work with multiple partition in Spring Cloud Stream(StreamListener)?
@StreamListener(value = PersonStream.INPUT)
private void personBulkReceiver(List<Person> person) {
//....
}
spring:
cloud:
stream:
kafka:
binders:
bulkKafka:
type: kafka
environment:
spring:
cloud:
stream:
kafka:
binder:
brokers: localhost:9092
configuration:
max.poll.records: 1500
fetch.min.bytes: 10000000
fetch.max.wait.ms: 10000
value.deserializer: tr.cloud.stream.examples.PersonDeserializer
bindings:
person-topic-in:
binder: bulkKafka
destination: person-topic
contentType: application/person
group : person-group
consumer:
batch-mode: true
我正在使用 Spring Cloud Stream 和 Kafka。在分区计数为 1 的 StreamListener 中,我可以每 5000 毫秒以批处理模式使用记录。
我的 .yml 配置是 fetch.min.bytes = 10000000 && fetch.max.wait.ms = 50000 && max.poll.records = 1500 如上所述。
我可以每 5000 毫秒接收一次批处理记录。因为批记录大小不超过 10000000 字节。
但是当分区数大于 1 时,StreamListener 会消耗早于 5000 毫秒的记录。
这个案例有什么配置吗?
或者这种情况是独立线程为每个分区工作的自然结果?
分区数大于1时,工作逻辑有什么不同?
根据您的自述文件...
And there is always a lot of data on the topic.
所以这与您所说的问题不符...
I can receive batch records in every 5000 ms. since batch record size doesn't exceed 10000000 bytes.
当数据多于此时,总会推送给客户端。
考虑改用 Polled Consumer,以您想要的速率接收数据。
@StreamListener(value = PersonStream.INPUT)
private void personBulkReceiver(List<Person> person) {
//....
}
spring:
cloud:
stream:
kafka:
binders:
bulkKafka:
type: kafka
environment:
spring:
cloud:
stream:
kafka:
binder:
brokers: localhost:9092
configuration:
max.poll.records: 1500
fetch.min.bytes: 10000000
fetch.max.wait.ms: 10000
value.deserializer: tr.cloud.stream.examples.PersonDeserializer
bindings:
person-topic-in:
binder: bulkKafka
destination: person-topic
contentType: application/person
group : person-group
consumer:
batch-mode: true
我正在使用 Spring Cloud Stream 和 Kafka。在分区计数为 1 的 StreamListener 中,我可以每 5000 毫秒以批处理模式使用记录。
我的 .yml 配置是 fetch.min.bytes = 10000000 && fetch.max.wait.ms = 50000 && max.poll.records = 1500 如上所述。
我可以每 5000 毫秒接收一次批处理记录。因为批记录大小不超过 10000000 字节。
但是当分区数大于 1 时,StreamListener 会消耗早于 5000 毫秒的记录。
这个案例有什么配置吗?
或者这种情况是独立线程为每个分区工作的自然结果?
分区数大于1时,工作逻辑有什么不同?
根据您的自述文件...
And there is always a lot of data on the topic.
所以这与您所说的问题不符...
I can receive batch records in every 5000 ms. since batch record size doesn't exceed 10000000 bytes.
当数据多于此时,总会推送给客户端。
考虑改用 Polled Consumer,以您想要的速率接收数据。