Oleg,

Agreed. As I started only a few months ago, I have been using AtomicReference and it has been reliable and satisfied all my needs. (Just sayin'.)

Best

On 04/14/2016 05:22 AM, Oleg Zhurakousky wrote:
A bit unrelated, but how do you guys feel if we deprecate ObjectHolder so it 
could be gone by 1.0?
AtomicReference is available from Java 5

Cheers
Oleg

On Apr 14, 2016, at 5:18 AM, Bryan Bende <[email protected]> wrote:

Hello,

It may be easier to move the load() out of the InputStreamCallback. You
could do something like this...

final ObjectHolder<String> holder = new ObjectHolder<String>(null);

session.read(flowFile, new InputStreamCallback() {

            @Override
            public void process(InputStream in) throws IOException {
                StringWriter strWriter = new StringWriter();
                IOUtils.copy(in, strWriter, "UTF-8");
                String contents = strWriter.toString();
                holder.set(contents);
            }
});

try {
        load(holder.get());
        session.transfer(flowFile, SUCCESS);
      } catch (IOException e) {
        session.transfer(flowFile, FAILURE);
}


-Bryan

On Thu, Apr 14, 2016 at 9:06 AM, idioma <[email protected]> wrote:

Hi,
I have modified my onTrigger in this way:

session.read(flowFile, new InputStreamCallback() {

            @Override
            public void process(InputStream in) throws IOException {

                StringWriter strWriter = new StringWriter();
                IOUtils.copy(in, strWriter, "UTF-8");
                String contents = strWriter.toString();

                try {
                    load(contents);
                } catch (IOException e) {
                    e.getMessage();
                    boolean error = true;
                    throw e;
                }
            }
        });

What I am struggling with is how to send it to a failure or a success
depending on the error being thrown. Any help would be appreciated, thank
you so much.



--
View this message in context:
http://apache-nifi-developer-list.39713.n7.nabble.com/catch-commit-error-in-OnTrigger-to-diversify-session-behaviour-tp9027p9062.html
Sent from the Apache NiFi Developer List mailing list archive at
Nabble.com.


Reply via email to