[英]How to publish message to 2 kafka topics based on condition - spring cloud stream
Currently i have a spring clound funtion which consumes a topic and publish in to another topic.目前我有一个 spring clound 函数,它使用一个主题并发布到另一个主题。 But for particular condition i need to publish message to another topic.
但对于特定情况,我需要将消息发布到另一个主题。 Basically need to publish message to multiple topic from spring cloud function.
基本上需要从 spring 云 function 向多个主题发布消息。
Current code snippets当前代码片段
@Bean
public Function<Message<InputMessage>, Message<OutputMessage>>
messageTransformer(){
return new KafkaTransformer();
}
public class KafkaTransformer
implements Function<
Message<InputMessage>, Message<OutputMessage>> {
@Override
public Message<OutputMessage> apply(
Message<InputMessage> inputMessage) {
try {
Message<OutputMessage> outputMessage = process(inputMessage);
return outputMessage;
} catch (Exception e) {
// need to send message to another topic ( which is other than dlq).
}
}
}
spring.cloud.stream.bindings.messageTransformer-in-0.destination=input.topic
spring.cloud.stream.bindings.messageTransformer-out-0.destination=output.topic
spring.cloud.function.definition=messageTransformer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.