Support Questions

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

Transfer relationship specified (Nifi)

avatar
New Contributor

hello

How can I make a flow (executeScript in groovy) be transferred to a destination that I want? Something similar with routeOnAttribute, but by code

sorry for the inconvenience

1 REPLY 1

avatar
Master Guru

ExecuteScript makes two relationships available, REL_SUCCESS and REL_FAILURE, you can use session.transfer(flowFile, relationship) to do the routing. Check my ExecuteScript Cookbook series (part 1) for examples on how to transfer a flow file. Once you have a boolean or other determining factor on where to route it, you can use the example to do the transfer.

If you have multiple relationships, and you can't use RouteOnAttribute due to the conditions being in the content, consider QueryRecord as you can use a SQL statement to do routing on the content. If that doesn't satisfy your use case, you can use InvokeScriptedProcessor to define relationships on the fly, based on some condition (perhaps user-defined properties like RouteOnAttribute and QueryRecord use). Consult the code for these processors for examples on how to implement this with InvokeScriptedProcessor.