You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by "Greene (US), Geoffrey N" <ge...@boeing.com> on 2020/10/26 20:12:18 UTC

RE: [EXTERNAL] Re: something not closing correctly in a session

Thank you!  That was it

-----Original Message-----
From: Bryan Bende [mailto:bbende@gmail.com] 
Sent: Monday, October 26, 2020 3:55 PM
To: users@nifi.apache.org
Subject: [EXTERNAL] Re: something not closing correctly in a session

This message was sent from outside of Boeing. Please do not click links or open attachments unless you recognize the sender and know that the content is safe.


Hello,

You can't call session.transfer inside the OutputStreamCallback, it needs to be done after the OutputStreamCallback is complete so that you are transferring the updated reference to flowFile.

Thanks,

Bryan

On Mon, Oct 26, 2020 at 3:49 PM Greene (US), Geoffrey N <ge...@boeing.com> wrote:
>
> I have  a groovy scripts that I am running inside of a 
> ExecuteGroovyScript processor (nifi v 1.12.0)
>
> I’ve been following the examples at https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-2/ta-p/249018, and I have something like:
>
>
>
> flowFile = session.get()
>
> if(!flowFile) return
>
> flowFile = session.write(flowFile, {outputStream ->
>
>    … do stuff
>
>     try {
>
>   …
>
>         // do thing that throws
>
>         …
>
>         outputStream.write(responseBytes)
>
>         session.transfer(flowFile, REL_SUCCESS)
>
>     }
>
>           catch {
>
>                // the below line ALWAYS throws
>
>               session.transfer(flowFile, REL_FAILURE)
>
>           } as OutputStreamCallback)
>
>
>
> But it throws an error at the session.transfer line.
>
>
>
> ExecuteGroovyScript[id=b3951944-10f5-1175-dfa8-3c9d28fe448e] 
> java.lang.IllegalStateException: 
> StandardFlowFileRecord[uuid=beef7ed3-1822-420d-839c-1c07b4f2d1c5,claim
> =StandardContentClaim 
> [resourceClaim=StandardResourceClaim[id=1603715925064-433, 
> container=default, section=433], offset=3086, 
> length=11],offset=0,name=6d7ccd7a-13be-43e1-b29b-0431bfaacec3,size=11] 
> already in use for an active callback or an OutputStream created by 
> ProcessSession.write(FlowFile) has not been closed: 
> java.lang.IllegalStateException: 
> StandardFlowFileRecord[uuid=beef7ed3-1822-420d-839c-1c07b4f2d1c5,claim
> =StandardContentClaim 
> [resourceClaim=StandardResourceClaim[id=1603715925064-433, 
> container=default, section=433], offset=3086, 
> length=11],offset=0,name=6d7ccd7a-13be-43e1-b29b-0431bfaacec3,size=11] 
> already in use for an active callback or an OutputStream created by 
> ProcessSession.write(FlowFile) has not been closed
>
>
>
> I’ve tried throwing around outputStream.close() everwhere, but that doesn’t seem to help.
>
>
>
> What am I missing?
>
>
>
> Thx
>
>
>
>
>
> Geoffrey Greene
>
> Senior Software Ninjaneer
>
> (703) 414 2421
>
> The Boeing Company
>
>