Christophe De Loeul
Christophe De Loeul

Reputation: 184

in nifi, how to call an external program that ask an input file and an output file in parameters

I have an external program, an ebook converter, to convert .epub to .txt. This converter requests a file as input and another file as output, the filenames are important here because the extension is used to determine which conversion should be made, also from what I saw while testing, the program is performing seeks on the input file. So those contrains prenvents usage of named pipes or SDTIN redirections.

For another project, or at least a POC, I'll have to encapsulated an existing bundle of tools that are working the same way as above and recreate the workflows bettween in Nifi.

In short term, writing a custom processor is not possible.

So how should i do it ?

here are a couple of possible solutions I found :

so what direction should I go, any advices ?

Upvotes: 1

Views: 1228

Answers (1)

James
James

Reputation: 11931

You are on the right track. I think you could do a sequence of processors like the following:

  1. UpdateAttribute - create attributes for the input and output file names.
  2. PutFile - write the temp input file.
  3. ExecuteProcess - run the conversion utility. I recommend wrapping this in a shell script, which gives you an opportunity to clean up the temp input file when it completes.
  4. FetchFile - read the conversion output into the FlowFile content. Use Completion Strategy of Delete File to clean up the converted file.

Upvotes: 2

Related Questions