Support Questions

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

NIFI:Using RouteOnContent for filtering responses?

avatar
Contributor

I want to use routeonContent and put my response in deifferenct directories based on the method names they consist i have attribute '$message.body' and use expression( in routeonContent) ${message.body:contains('<person>')} . But it doesn't work for me do you have any better idea how can i do this?

I need to check if it conatains tag with name person and if it does o will route it to certian direction.

I have replaced ${message.body:contains('<person>')} with this ${message.body:contains("<[^>][+ person+^>]*>")} but it still doesn't works.

1 ACCEPTED SOLUTION

avatar
Master Guru

@sally sally

Route on content is to match the contents of ff we cannot compare attribute inside this processor.

But we can acheive by using

RouteOnAttribute Processor:-

as we are having ${message.body} as attribute then add a property

${message.body:contains('<person>')}

it will look for message.body attribute contains <person> or not.

40530-routeonattribute-person.png

if yes then it routes to person relation and

if ff not having <person> it will routes to unmatched relation.

RouteOnContent Processor:-

As you are having $message.body as attribute we are not able to use RouteOnContent processor, because it will look the content of ff to find match.

E.g:-How RouteOnContent works?
Input:-

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <person>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

If we are having the above input as the ff content then in Route on content processor we need to give property as

40531-routecontent.png

It will look for is the content of ff having <person> or not

In our case it is yes then it will route to person relation.

View solution in original post

2 REPLIES 2

avatar

avatar
Master Guru

@sally sally

Route on content is to match the contents of ff we cannot compare attribute inside this processor.

But we can acheive by using

RouteOnAttribute Processor:-

as we are having ${message.body} as attribute then add a property

${message.body:contains('<person>')}

it will look for message.body attribute contains <person> or not.

40530-routeonattribute-person.png

if yes then it routes to person relation and

if ff not having <person> it will routes to unmatched relation.

RouteOnContent Processor:-

As you are having $message.body as attribute we are not able to use RouteOnContent processor, because it will look the content of ff to find match.

E.g:-How RouteOnContent works?
Input:-

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <person>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

If we are having the above input as the ff content then in Route on content processor we need to give property as

40531-routecontent.png

It will look for is the content of ff having <person> or not

In our case it is yes then it will route to person relation.