2
votes

I am new to Apache NiFi and I am trying to solve the following scenario:

I have a file in the following format: @RTOajvnodsnvodsvdsonbbvoiroi uvdsoiuvoibvds @RBCinbdiuvidsnb

Each line is terminated by a new line character. The first and last lines are the header and footer lines. I need to check whether the header and footer lines have @RTO and @RBC respectively or not. If yes, I would need to route the flow file.

I am trying to use the RouteOnContent processor to achieve this, using the regular expression (@RTO)[\\S\\s\\w\\W]*(@RBC)[\\S\\s\\w\\W]*. I tested it in Java and it works out, but it does not work in NiFi.

The processor properties screenshot is attached- enter image description here

1
Could you attach a screenshot of the config of your RouteContent processor? - JDP10101
I have added an image of the processor properties. - Saharsh Kislaya

1 Answers

1
votes

I think your regex isn't quite sufficient to match the newlines. I've created a template with a working version (\A(@RTO)(.*\n)*(@RBC).*\z). This template generates flowfiles and populates them with either:

  • The header and footer flags as you provided above
  • Only the header
  • Only the footer
  • Neither

and then routes them accordingly. I took your description to be "header and footer present" or "other", but you can modify to fit your needs.