Skip to main content

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.

note

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. Example of default Processor Relationships

Parameters:

NameTypeDescription
nameStringName of the relationship.
descriptionStringExplanation of the reason FlowFile may be routed to this relationship.
auto_terminatedBoolean; Default FalseAllow 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.

note

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.