- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
send kafka topic as header when publishing data to another topic in NIFI
- Labels:
-
Apache NiFi
Created 11-24-2023 01:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i want to send value of kafka.topic as header i.e (the topic from where i consumed message) to publish topic (another topic) by using publish processor.
But iam getting below error in publish processor-
Created 11-24-2023 09:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error tells you it needs to be a regular expression matching the attribute you wish to send so if it's kafka.topic it could be that literally or more accurately would be kafka\.topic
Created 11-26-2023 08:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
kafka.topic is a key , it will have value of a kafka topic name e.g abc_xyz .
this value will keep on depending from where iam consuming the meassge , from which topic .
my requirement is to send the topic from where i consumed as header to the topic where iam publishing it .
how can i do that ??
Created 11-26-2023 05:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the regular expression it's asking for is that of the attribute containing the value you want... It's not asking for the value. Since you want the value of the attribute kafka.topic (name/key) then this is what the regular expression you need to match. Have you tried just putting what I previously recommended "kafka\.topic"?
Created 11-28-2023 05:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
kafka\.topic , i tried adding this , but it did not work . I checked kafka headers too there also nothing being printed in haeder.
Created 11-28-2023 05:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@joseomjr Is on to the right solution here. Your regex statement should match "kafka.topic" not "${kafka.topic}". A quick test in regex101.com confirms "kafka\.topic" should match.