小编Gat*_*sko的帖子

从Apache Camel中的特定Offset开始阅读Kafka主题

我阅读了Camel Kafka的所有文档,我读到的唯一方法是来自git和指定的路由构建器

    public void configure() throws Exception {
                    from("kafka:" + TOPIC
                                 + "?groupId=A"
                                 + "&autoOffsetReset=earliest"             // Ask to start from the beginning if we have unknown offset
                                 + "&consumersCount=2"                     // We have 2 partitions, we want 1 consumer per partition
                                 + "&offsetRepository=#offset")            // Keep the offset in our repository
                            .to("mock:result");

}
Run Code Online (Sandbox Code Playgroud)

但是对于客户的订单,我需要使用Spring,所以我的kafka端点就是这样

<!--DEFINE KAFKA'S TOPCIS AS ENDPOINT-->
        <endpoint id="tagBlink" uri="kafka:10.0.0.165:9092">
            <property key="topic" value="tagBlink"/>
            <property key="brokers" value="10.0.0.165:9092"/>
            <property key="offsetRepository" value="100"/>
        </endpoint>
Run Code Online (Sandbox Code Playgroud)

但得到一个例外

无法为属性找到合适的setter:offsetRepository,因为没有相同类型的setter方法:java.lang.String也不能进行类型转换:没有类型转换器可用于从类型:java.lang.String转换为所需类型:org.apache.camel.spi.StateRepository,值为100

这是我的当前配置吗?如何从特定偏移恢复??

java apache-camel apache-kafka

6
推荐指数
1
解决办法
909
查看次数

标签 统计

apache-camel ×1

apache-kafka ×1

java ×1