简体   繁体   English

来自另一条消费者路线的输入的骆驼消费者路线

[英]Camel consumer route with input from another consumer route

I have a kafka consumer route from where I get some data.我有一条 kafka 消费者路线,我从那里获取一些数据。

from("Kafka:foo?brokers=localhost:9092")

Once I receive data from the consumer, use that data in the topic name for a paho mqtt consumer.一旦我从消费者那里收到数据,就在 paho mqtt 消费者的主题名称中使用该数据。

from("paho:#?brokerUrl=tcp://localhost:1883")

I'm not able to figure out how to set the dynamic header CamelMqttTopic, from first consumer, as both seems independent flows.我无法弄清楚如何从第一个消费者设置动态 header CamelMqttTopic,因为两者似乎都是独立的流程。 I'm using camel with Spring framework.我正在使用带有 Spring 框架的骆驼。 Excuse me if my basic camel understanding is flawed.如果我对骆驼的基本理解有缺陷,请原谅。

You can override the MQTT topic using the CamelPahoOverrideTopic message header with a value being the Kafka topic accessed through the kafka.TOPIC message header:您可以使用CamelPahoOverrideTopic消息 header 覆盖MQTT主题,其值为通过kafka.TOPIC消息 header 访问的Kafka主题:

from("kafka:foo?brokers=localhost:9092")
    .setHeader(PahoConstants.CAMEL_PAHO_OVERRIDE_TOPIC, simple("${headers[kafka.TOPIC]"))
    .to("paho:#?brokerUrl=tcp://localhost:1883");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM