- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Transfer relationship specified (Nifi)
- Labels:
-
Apache NiFi
Created ‎05-30-2018 10:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎05-30-2018 11:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
