Russell, May not be too bad to fix :)
Any time you use a method on ProcessSession to modify a FlowFile in some way (such as putAttribute, putAllAttributes, write, removeAttribute, removeAllAttributes, etc.) the ProcessSession returns to you a new FlowFile. So you *should* write code such as: ``` FlowFile flowFile = session.get(); If (flowFile == null) { return; } flowFile = session.write(flowFile, new OutputStreamCallback() { … }); flowFile = session.putAttribute(flowFile, “greeting”, “hello”); session.transfer(flowFile); ``` Note here that calls to session.write, session.putAttribute are capturing the return value and holding on to that. That was necessary in older versions. If you instead wrote: ``` flowFile = session.get(); session.write(flowFile, new OutputStreamCallback() { … }); session.putAttribute(flowFile, “greeting”, “hello”); ``` The call to session.putAttribute would throw an Exception because you provided an outdated version of the flowFile (did not capturing the result of calling session.write) Now, as NiFi matured, we found that: (a) for more complex processors that aren’t just a series of sequential steps it becomes difficult to manage all of that bookkeeping. (b) it was not intuitive to require this (c) the ProcessSession already had more or less what it needed in order to determine what the most up-to-date version of the FlowFile was. So we updated the ProcessSession to automatically grab the latest version of the FlowFile for these methods. But since you’re trying to run an old version, you’ll need to make sure that you capture all of those outputs and always keep track of the most recent version of a FlowFile. You’ll also need to ensure that you’re not calling any methods, etc. that didn’t exist in the 1.1.2 API :) Thanks -Mark > On May 7, 2024, at 1:38 PM, Russell Bateman <r...@windofkeltia.com> wrote: > > In /pom.xml/ I specify using NiFi framework libraries from 1.13.2. > > There are peculiar reasons (that we are trying to fix) that inhibit us from > moving forward as all of our customer machines are running 1.1.2. (Don't > shoot me, I'm not DevOps, but just the guy who writes custom processors.) > > I have custom processor code that, built as noted using 1.13.2, runs > _perfectly_ on any version of NiFi from 1.13.2 to 1.25.0. When loaded on > 1.1.2, one processor fails to process a very simple flowfile with the error > message below. > > I'm wondering if there's a dance I can do to tweak one or more of what I > suspect are the calls where this is happening (in onTrigger()): > > FlowFile result = session.*write*( flowfile, new StreamCallback() > session.*read*( flowfile, new InputStreamCallback() > session.*removeAllAttributes*( result, keys ); > session.*putAllAttributes*( result, attributes ); > session.*transfer*( result, SUCCESS ); > > > Error message: > > 10:32:47 MDTERRORc78b2d48-79a6-39ae-1454-4ee57bbf8928 > ExcerptWarehouseResponse[id=c78b2d48-79a6-39ae-1454-4ee57bbf8928] \ > failed to process session due to > org.apache.nifi.processor.exception.FlowFileHandlingException: \ > StandardFlowFileRecord[uuid=cfb2a124-4b07-46bd-a70e-3848502b3df1,claim=StandardContentClaim > \ > [resourceClaim=StandardResourceClaim[id=1715094869203-1, container=default, > section=1], offset=0, > length=1077766],offset=0,name=30575811037248611,size=1077766] \ > is not the most recent version of this FlowFile within this session > (StandardProcessSession[id=3923]): \ > org.apache.nifi.processor.exception.FlowFileHandlingException: > StandardFlowFileRecord[uuid=cfb2a124-4b07-46bd-a70e-3848502b3df1,claim=StandardContentClaim > \ > [resourceClaim=StandardResourceClaim[id=1715094869203-1, container=default, > section=1], offset=0, > length=1077766],offset=0,name=30575811037248611,size=1077766] \ > is not the most recent version of this FlowFile within this session > (StandardProcessSession[id=3923]) > > 10:32:47 MDTWARNINGc78b2d48-79a6-39ae-1454-4ee57bbf8928 > ExcerptWarehouseResponse[id=c78b2d48-79a6-39ae-1454-4ee57bbf8928] Processor > Administratively Yielded for 1 sec due to processing failure > > > I know this is old stuff and I'm prepared be told that I'm out of luck or > that the solution is unfeasible or would take too much effort to dig through. > I'm just hoping that someone remembers something quick off the top of the > head and can give advice. > > Thanks, > > Russ > > > > >