marklogic / nifi

Mirror of Apache NiFi to support ongoing MarkLogic integration efforts
https://marklogic.github.io/nifi/
Apache License 2.0
12 stars 23 forks source link

CallRestExtensionMarkLogic does not output FlowFile to results relationship #210

Closed eaolson closed 7 months ago

eaolson commented 9 months ago

I've just switched my flow from ExtensionCallMarkLogic to CallRestExtensionMarkLogic after upgrading to 1.16, since it's deprecated. Where ECML had success and failure relationships, CREML has original, failure, and results. I would expect an FlowFile to be output to the results relationship on success, but that's not happening. My extension just adds some XML elements to the target, so it just returns an empty sequence.

Looking at CallRestExtensionMarkLogic.java, it looks like nothing is sent to the results relationship is null. I think this means there's no way to continue processing only those FlowFiles that did not experience an error, since since I think FlowFiles are are sent to original whether or not they succeed.

image

rjrudin commented 9 months ago

Hi @eaolson - if a failure occurs in the call to MarkLogic, then the processing specific to CallRestExtensionMarkLogic will never be called and the original FlowFile will be sent to failure. If the call succeeds, which would include when the extension returns nothing, then the FlowFile will be sent to original.

So for your use case, I believe you can use the original relationship to continue processing of the FlowFile. This seems logical to me - it's like invoking a void method, where processing should continue with the current data.

I think you're suggesting instead that if the extension returns nothing, perhaps a new FlowFile should be created and routed to results? That would be a doable change, but I think that may be more unintuitive, given that there are no results.

eaolson commented 9 months ago

I guess what I'm mostly pointing out is that with CallRestExtensionMarkLogic, is that results + failure != original. Since the original relationship contains both the successful and failed FlowFiles, so there's no way to continue process with only the ones that suceeded. This just seems different from most NiFi processors with an original relationship, where the other relationships are some sort of error condition and non-error condition, e.g. QueryMarkLogic, InvokeHTTP.

In my case, I think I can probably just add some non-blank output to my extension so the successful FlowFiles will be routed to results.

rjrudin commented 9 months ago

Are you getting an error that results in the FlowFile going to original instead of failure? Any error in the call to MarkLogic should be logged with the original FlowFile being sent to failure. If not, that would certainly be a bug in the processor.

rjrudin commented 7 months ago

@eaolson Following up here - I verified that if I have a REST extension that does not return anything, the incoming FlowFile will be sent to original, regardless of whether the REST extension returns any data.

If the REST extension returns a sequence of one or more items, a FlowFile is created for each item and sent to results.

If I modify the REST extension to throw an error, the incoming FlowFile will be sent to failure.

I believe that gives a user everything they need, so I am closing this ticket but please continue the conversation here if you believe an enhancement is needed.