nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From idioma <>
Subject Re: Is my custom processor doing too many things? OnTrigger question
Date Mon, 18 Apr 2016 14:03:57 GMT
Thanks Oleg,
would this be what I want? 

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

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

        final String userId = context.getProperty(USER_ID).getValue();
        final String password = context.getProperty(PASSWORD).getValue();
        final String http_post_url =

        final AtomicReference<String> httpPostRequestHolder = new
AtomicReference<>();, new InputStreamCallback() {
            public void process(InputStream inputStream) throws IOException
                StringWriter strWriter = new StringWriter();
                IOUtils.copy(inputStream, strWriter, "UTF-8");

        try {
            postHttpRequest(userId, password, source, message,
http_post_url, resource_ids_file_path);
            session.transfer(flowFile, SUCCESS);
        } catch (IllegalArgumentException ex) {
            session.transfer(flowFile, FAILURE);

        flowFile = session.create();
        flowFile = session.write(flowFile, new OutputStreamCallback() {
            public void process(OutputStream out) throws IOException {

        session.transfer(flowFile, SUCCESS);

is this the correct way to write out the JSON response?

View this message in context:
Sent from the Apache NiFi Developer List mailing list archive at

View raw message