Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

NIFI:Using RouteOnContent for filtering responses?

Solved Go to solution

NIFI:Using RouteOnContent for filtering responses?

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

Accepted Solutions

Re: NIFI:Using RouteOnContent for filtering responses?

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

2 REPLIES 2

Re: NIFI:Using RouteOnContent for filtering responses?

Re: NIFI:Using RouteOnContent for filtering responses?

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

Don't have an account?
Coming from Hortonworks? Activate your account here