You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NiFi是否支持在自定义处理器中将单个FlowFile转发至多个Relationship?

NiFi: Forwarding a Single FlowFile to Multiple Relationships

Hey there! Let's break down your questions about NiFi processor behavior clearly:

1. Does NiFi support forwarding a single FlowFile to multiple Relationships in a processor?

Yes, NiFi absolutely supports this scenario—but there's a critical detail to keep in mind: you can't directly transfer the same FlowFile instance to multiple Relationships. Each FlowFile can only be transferred once within a session, since transferring it removes it from the session's working set. To send the same data to multiple Relationships, you need to create copies (clones) of the original FlowFile first.

2. How to implement forwarding a single FlowFile to two or more Relationships in a custom processor?

It's true the official docs don't spell this out step-by-step, but this is a common use case that's fully supported. The core trick is to use NiFi's session.clone() or session.copy() methods to create duplicates of the original FlowFile, then transfer each duplicate (plus the original if needed) to your target Relationships.

Here's a corrected, working version of your example code:

// Clone the original FlowFile to create an identical duplicate
FlowFile clonedFlowFile = session.clone(flowFile);

// Transfer the original FlowFile to the first success relationship
session.transfer(flowFile, REL_SUCCESS_1);

// Transfer the cloned FlowFile to the second success relationship
session.transfer(clonedFlowFile, REL_SUCCESS_2);

// Always commit the session to finalize all operations
session.commit();

Why your original code wouldn't work:

When you call session.transfer(flowFile, REL_SUCCESS_1), NiFi removes the original FlowFile from the session's working queue. Trying to transfer the same instance again with session.transfer(flowFile, REL_SUCCESS_2) would throw an error, as the FlowFile is no longer tracked by the session.

If you need to send the data to more than two Relationships, just create additional clones and transfer each one to the respective Relationship.

内容的提问来源于stack exchange,提问作者Sateesh Telaprolu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:27:06