Apache Nifi:有没有办法使用消息键作为多个属性的组合将消息发布到 kafka? [英] Apache Nifi: Is there a way to publish messages to kafka with a message key as combination of multiple attributes?
问题描述
我有一个要求,我需要读取 CSV 并以 Avro 格式发布到 Kafka 主题.在发布过程中,我需要将消息键设置为两个属性的组合.假设我有一个名为 id 的属性和一个名为 group 的属性.我需要我的消息键是 id+"-"+group.有没有办法在 Apache nifi 流中实现这一点?将消息键设置为单个属性对我来说很好用.
I have a requirement where I need to read a CSV and publish to Kafka topic in Avro format. During the publish, I need to set the message key as the combination of two attributes. Let's say I have an attribute called id and an attribute called group. I need my message key to be id+"-"+group. Is there a way I can achieve this in Apache nifi flow? Setting the message key to a single attribute works fine for me.
推荐答案
注意每个属性上的 (?)s 指示什么是允许或不允许的:
Notice the (?)s on each property which indicates what is or isn't allowed:
当字段不包含表达式语言时,请使用 updateAttribute 处理器来设置您需要的组合值.然后在下游使用组合值.
When a field doesn't except expression languages, use an updateAttribute processor to set the combined value you need. Then you use the combined value downstream.
这篇关于Apache Nifi:有没有办法使用消息键作为多个属性的组合将消息发布到 kafka?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!