Support Questions

Find answers, ask questions, and share your expertise

Proof whether flowfile content already exists in database - NIFI

avatar
Explorer

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 6

avatar
Super Guru

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?

avatar
Explorer

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!

avatar
Super Guru

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.

avatar
Explorer

Thanks! That sounds like a good solution.

Is it possible that you send me the configuration of your LookupRecord Processor? 🙂 

avatar
Explorer

Hello again 🙂 I'm currently struggling with telling the LookupRecord to use multiple columns as key (same in DatabaseRecordLookupService). It would be awesome if you could help me with this!

Many thanks!

avatar

Hi i am wokring on it can you share me the flow file configuration and sp it will helpful to me