About Relationship
Class
nifiapi.relationship.Relationship
Relationships define the routes to which a FlowFile may be transferred from a Processor. By default, there are three relationships available to each processor: success
, failure
and original
.
original
relation is automatically populated by the framework, and should not be called from the code.
You can define additional routes by defining additional relationships.
Parameters:
Name | Type | Description |
---|---|---|
name | String | Name of the relationship. |
description | String | Explanation of the reason FlowFile may be routed to this relationship. |
auto_terminated | Boolean; Default False | Allow FlowFile to be automatically removed from Flow when routed to relationship. |
e.g.:
from nifiapi.relationship import Relationship
RELATION = Relationship(
name="success",
description='''
A FlowFile is routed to this relationship after the database is
successfully updated.
''',
auto_terminated=False
)
Registering relationships
Any additional relationships available to the Processor must be defined in the getRelationships
method.
Relationships failure
and original
are always available, no matter the changes made.
from nifiapi.flowfiletransform import FlowFileTransform
from nifiapi.relationship import Relationship
from typing import List
class Processor(FlowFileTransform):
(...)
RELATION = Relationship(
name="custom",
description='''
A FlowFile is routed to this relationship when ..
''',
auto_terminated=False
)
def getRelationships(self) -> List[Relationship]:
'''
Register processor relationships.
Returns:
list(Relationship)
'''
return [
self.RELATION,
]
Note that in the following example, as we modified the available relationships and registered an additional custom
one. All currently available relationships for the FlowFile will be: failure
, original
, and custom
.