Reputation: 299
I have following workflow:
ConsumeKafkaData->EvaluateJsonFlow->UpdateRecord->Putfile.
I am having following simple JSON message: {"name":"Yeshwant","active":false}
In EvaluateJsonPath, I created one attribute "name" in configuration which is linked to "name" attribute of above json data.
In UpdateAttribute processor, I created one rule that when value of "name" equals to "dummy" then changed to "funny". I am able to change the value of attribute "name" to value "funny". But the input and output json data did not channge. why? How does UpdateAttribute changes data in JSON directly? is there any configuration I am missing?
Even at PutFile processor I don't see json data changed.
Thanks Yeshwant
Upvotes: 1
Views: 6480
Reputation: 31470
In the existing flow you are changing the value of the attribute associated to the flowfile
not the actual content of the flowfile.
After UpdateAttribute processor use AttributesToJson processor and recreate your Output JSON content.
Flow:
1. ConsumeKafkaData
2. EvaluateJsonFlow //Extract all json data attributes as flowfile attributes
3. UpdateAttribute
4. AttributeToJSON //AttributesList -> name,active; Destination -> flowfile Content
5. Putfile
For more details/usage of AttributesToJSON processor refer to this link.
In addition you can use Record oriented processors for this case i.e. UpdateRecord/QueryRecord
processor then use LiteralValue strategy and use Expression language
if-else
on the value of name
attribute.
In case if you are using QueryRecord processor
then write a case statement in your sql query.
Refer this link for more details/usage updateRecord processor.
Refer this link for more details/usage of QueryRecord processor.
Upvotes: 4