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 =
context.getProperty(HTTP_POST_URL).getValue();

        final AtomicReference<String> httpPostRequestHolder = new
AtomicReference<>();
        session.read(flowFile, new InputStreamCallback() {
            @Override
            public void process(InputStream inputStream) throws IOException
{
                StringWriter strWriter = new StringWriter();
                IOUtils.copy(inputStream, strWriter, "UTF-8");
                httpPostRequestHolder.set(userId);
                httpPostRequestHolder.set(password);
                httpPostRequestHolder.set(http_post_url);
            }
        });

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

        flowFile = session.create();
        flowFile = session.write(flowFile, new OutputStreamCallback() {
            @Override
            public void process(OutputStream out) throws IOException {
                out.write(httpPostRequestHolder.get().getBytes());
            }
        });

        session.transfer(flowFile, SUCCESS);

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





--
View this message in context: 
http://apache-nifi-developer-list.39713.n7.nabble.com/Is-my-custom-processor-doing-too-many-things-OnTrigger-question-tp9225p9238.html
Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.

Reply via email to