Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Apache Nifi read streaming

Apache Nifi read streaming

New Contributor

I’m using a listentcp connected to a custom processor and I would like to read correctly the stream in this custom processor.

I'm using this way in this custom processor :

 

public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {

 

       FlowFile flowfile = session.get();

       byte[] buf = new byte[(int) flowfile.getSize()];

 

       session.read(flowfile, new InputStreamCallback() {

       @Override

       public void process(InputStream in) throws IOException {

          StreamUtils.fillBuffer(in, buf);

            //use of buf…      

       }

    }

}

 

but I see that the data are not cut correctly in the flowfiles, there are some remaining bytes belonging to the next packet of the next flowfile at the end of the current flow file, making the next packet invalid.

Is there a way to handle this efficiently ?

Don't have an account?
Coming from Hortonworks? Activate your account here