apache-kafka - 消息没有被消费
问题描述
我在带有 Camel 实现的 Spring Boot 的 application.properties 文件中添加了以下配置,但消息没有被消耗。我是否缺少任何配置?使用 kafka 协议和 Camel 从 Azure 事件中心实现消费者的任何指针?
bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}";
路线如下所示:
from("kafka:{{topicName}}?brokers=NAMESPACENAME.servicebus.windows.net:9093" )
.log("Message received from Kafka : ${body}");
解决方案
我找到了这个问题的解决方案。由于我使用的是 Spring Boot Auto 配置(camel-kafka-starter),因此必须修改 application.properties 文件中的条目,如下所示:
camel.component.kafka.brokers=NAMESPACENAME.servicebus.windows.net:9093
camel.component.kafka.security-protocol=SASL_SSL
camel.component.kafka.sasl-mechanism=PLAIN
camel.component.kafka.sasl-jaas-config =org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}";
使用 Kafka 协议的 Azure 事件中心的消费者路由将如下所示:
from("kafka:{{topicName}}")
.log("Message received from Kafka : ${body}");
希望此解决方案有助于使用 Kafka 协议从 Camel 中的 Azure 事件中心消费事件
推荐阅读
- c# - 使用 SerializationBinder 和 Surrogate 更新数据对象
- php - ORA-01036: oci_bind_by_name() 上的非法变量名称/编号
- javascript - JavaScript If 语句未正确比较变量
- html - 如何使用 CSS 在 n 个字符后中断?
- java - 如何使用 SnakeYaml 对 YAML 中的节点进行排序?
- c - 浅/深拷贝术语是否适用于没有引用的对象?
- postgresql - 从子查询 postgresql 更新列中的所有字段
- java - 为什么没有使用 Postgres docker hub 映像在我的 docker 映像中安装 Java
- c# - 为什么我的 Button 不适用于 Unity 类中的方法?
- python - 在 Pandas 中使用 .columns