如何在 Camel K Kafka URL 中使用 ${...}? [英] How to use ${...} in Camel K Kafka URL?

查看:21
本文介绍了如何在 Camel K Kafka URL 中使用 ${...}?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将主题保存在标题中并尝试在 Kafka URL 中访问它,如下所示:

I have saved topic in header and try to access it in the Kafka URL as below:

from(...)
.process(...)
.to("kafka:${header.topic}?brokers=localhost:9092")

不幸的是它说Kafka URL无效:

Unfortunately it says the Kafka URL is invalid:

org.apache.kafka.common.errors.InvalidTopicException: Invalid topics: [${header.topic}]

我尝试用 .log("${header.topic}") 替换 to(...) 并且可以打印预期值在日志行中.

I have tried replace the to(...) with .log("${header.topic}") and the expected value can be printed in the logline.

有谁知道是什么导致了这个问题,我应该转义美元符号还是花括号?

Does anyone know what causes the issue, am I supposed to escape the dollar sign or the curly braces?

推荐答案

你需要使用 send dynamic 所以用 toD 替换 to

you need to use send dynamic so replace to with toD

这篇关于如何在 Camel K Kafka URL 中使用 ${...}?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆