首页 > 解决方案 > 消息没有被消费

问题描述

我在带有 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}"); 

标签: apache-kafkaapache-camelazure-eventhubspring-camel

解决方案


我找到了这个问题的解决方案。由于我使用的是 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 事件中心消费事件


推荐阅读