Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Proof whether flowfile content already exists in database - NIFI

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!

5 REPLIES 5

Super Collaborator

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?

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!

Super Collaborator

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.

Explorer

Thanks! That sounds like a good solution.

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

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!

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.