Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

send kafka topic as header when publishing data to another topic in NIFI

avatar
Contributor

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- 

Screenshot1.pngScreenshot2.png

5 REPLIES 5

avatar
Super Collaborator

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

avatar
Contributor

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 ??

avatar
Super Collaborator

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"?

avatar
Contributor

kafka\.topic  , i tried adding this  , but it did not work . I checked kafka headers too there also nothing being printed in haeder.

avatar

@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.