Thank you very much Matt. I'll make that refinement right now and reprocess my data collection. -Jim.
On Tue, Jan 23, 2018 at 1:08 PM, Matt Burgess <[email protected]> wrote: > Jim, > > If you only need to read the contents of the flow file and not modify > them, then you don't have to use session.write() to send the original > content out, you can just use session.read(FlowFile, > InputStreamCallback) instead. > > I'm not sure why that write fails sometimes and not others, I suspect > it is something either in the particular input or perhaps a bug in > Jython. > > Regards, > Matt > > > On Tue, Jan 23, 2018 at 11:23 AM, James McMahon <[email protected]> > wrote: > > Good afternoon. I have a python script that attempts to execute a stream > > callback. I use re to extract content out of the incoming stream > represented > > as a string. After extracting the content I need, I save these as > attributes > > and attempt to write back my original content to the output stream. It > works > > almost all the time, but occasionally the ExecuteScript processor hangs > with > > the error message: > > TypeErro: write(): 1st arg can't be coerced to byte[], int in script at > line > > number 184 > > > > I use an ExecuteScript with python as the ScriptEngine. > > Line 184 in my script folds the call to the callback into a > session.write, > > like so: > > flowFile = session.write(flowFile, PyStreamCallback()) > > > > In my callback method I catch the contents of my stream in a string, like > > so: > > trailer = IOUtils.toString(inputStream,StandardCharsets.UTF_8) > > I use re expressions to pattern match for nuggets I later save as > > attributes. > > > > I use this to output back to my stream: > > outputStream.write(bytearray(trailer.encode('utf-8'))) > > This almost always works, but fails on rare occasions because, well, I > don't > > think I'm smart enough to know how to bullet-proof the output stream > write. > > > > Can anyone show me how to modify this outputStream.write to overcome this > > impediment? Bottom line: I simply want to send the inputStream back to > the > > outputStream at this point (I have saved all i parsed out to a python > > dictionary accessible to me later in my script). If there's a better > form of > > the outputStream write I am using that directly references the input > stream, > > that may eliminate my impediment. > > > > I am running on an older version of Apache NiFi, 0.7.x. > > > > Thanks very much for any assistance, > > Jim >
