Skip to main content
code
Silver ⭐️⭐️
August 5, 2022
Question

Proof whether flowfile content already exists in database - NIFI

Hi,

I have one flowfile with data I get from an external source (stock of a supplier). The products are already in a database. So now I have to check whether the stock has changed. If the stock of my flowfile is equal to the one in the database, I don't want to write the entry into the database (avoid duplicates).

Maybe someone of you has an idea how to implement this best.

Many thanks for your help!

6 replies

SAMSAL
Platinum ⭐️⭐️⭐️
August 5, 2022

Hi ,

 

What is the flowfile content format? Is there an Id you can check using the LookupRecord processor to see if the record already exists or not?

Translate
code
codeAuthor
Silver ⭐️⭐️
August 8, 2022

Hey,

thanks for your answer!

I use UpdateRecordProcessor so the format can be whatever it needs to be 🙂 JSON, CSV, Avro... I don't care.

There is a product id in both flowfiles. But most of the time the id is already in the database but just with another stock. So just checking whether the id already exists or not is not enough.

Thank you!

Translate
SAMSAL
Platinum ⭐️⭐️⭐️
August 8, 2022

The lookupRecrod processor allows you to specify multiple lookup columns in the DatabaseRecordLookupService incase the id is not enough. I had a similar sitution and I usually defer this kind of check to the DB, so my workflow will call stored proc - with the record parameters - that will check if the record exist or not and based on that decide wither to update or insert. This way Im making only one connection to the DB.

Translate