Mark Payne created NIFI-2039:
--------------------------------

             Summary: Provide ability to get InputStream from FlowFile without 
using Process Session callback
                 Key: NIFI-2039
                 URL: https://issues.apache.org/jira/browse/NIFI-2039
             Project: Apache NiFi
          Issue Type: Improvement
          Components: Core Framework
            Reporter: Mark Payne
             Fix For: 1.0.0


Provide a mechanism to obtain an InputStream for a FlowFile directly from the 
ProcessSession without having to provide an InputStreamCallback.

Currently, we often have processors that create an AtomicReference so that the 
value can be set within a callback and then the value must be obtained using a 
get() once the callback returns. This is very un-intuitive. Additionally, we 
don't have the ability to return an InputStream to other code that may required 
to run in a callback. For instance, when using Calcite, Calcite wants a 
callback, essentially, that provides an Enumerator of data. We can't currently 
support this well because we can't create an InputStream and return it.

We need to add the following method to ProcessSession:

InputStream read(FlowFile flowFile) throws ProcessException;

The InputStream that is returned must be tracked by ProcessSession such that 
when the session is committed or rolled back, the stream is closed if it hasn't 
been already. All of the logic that currently takes place in 
ProcessSession.read() after the callback returns must be done on the closing of 
the new InputStream that is returned.

The MockProcessSession should throw an Exception if commit() is called without 
the InputStream being closed, ideally providing the stack trace of where the 
stream was obtained and where commit() was called. This is to ensure that the 
developer is being a good consumer, but the StandardProcessSession doesn't 
really need to do this, as we can simply close the InputStream so that it can 
no longer be consumed.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to