我们将 Azure 事件中心与 Kafka 集成选项结合使用。我们的服务基于Java、Spring Boot、Spring Cloud Stream。它们部署在 Azure AKS 上。我们已在群集的虚拟网络上为 Azure 事件中心启用服务终结点。
大多数时候,一切正常。
生产者有时无法发布到 Kafka。我们会丢失消息,这通常对于整体数据一致性至关重要。
发生这种情况时,我们会在日志中看到一些错误(为了便于阅读,我已将它们分解为多行):
日志中的第一个示例:
2019-02-21 22:11:04.681 WARN 1 --- [ad | producer-2]
o.a.k.clients.producer.internals.Sender : [Producer clientId=producer-2]
Got error produce response with correlation id 6 on topic-partition _topic-name_-1,
retrying (4 attempts left). Error: NETWORK_EXCEPTION
第二个例子:
org.apache.kafka.common.errors.TimeoutException:
Expiring 1 record(s) for _topic-name_-1:
30096 ms has passed since batch creation plus linger time
消费者偶尔也会遇到连接问题:
2019-02-22 03:03:59.733 INFO 1 --- [container-0-C-1]
o.a.k.c.c.internals.AbstractCoordinator :
[Consumer clientId=consumer-6, groupId=my-super-service]
Group coordinator my-super-hub.servicebus.windows.net:9093
(id: 2147483647 rack: null) is unavailable or invalid, will attempt rediscovery
有人对 Azure 事件中心有类似的问题吗?也许对可能出现的问题有一些想法?
最佳答案
您需要设置最大连接空闲时间。
connections.max.idle.ms
祝你好运。
关于java - Azure 事件中心与 Spring Cloud Stream Kafka 的连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54825091/