Hi,
I have a custom Apache NiFi processor whose aim is to load a sample graph
into Titan Db. I have a load method that creates the graph with a few
vertices/edges and commits the transaction (transaction.commit() is wrapped
around a try/catch block to catch any TitanException). Inside my On Trigger
I have the following:

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

        FlowFile flowFile = session.get();
        if (flowFile == null) return;

        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.printStackTrace();
                }
            }
        });
}

The load method takes a string, which is the conversion from the InpuStream.
I am trying to find a way to, according to the commit being successfully or
not, jump into a session.rollback(true); session.transfer(flowFile, FAILURE)
or session.transfer(flowFile, SUCCESS)

Can you help please?



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

Reply via email to