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.
>