Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

NIFI: Stop a processor automatically & reroute flow files.

avatar
Contributor

I am a newbie in NIFI, Please, i need help.
I am updating DB using NIFI.
I have two(2) DB servers.
One of the DB is a backup in case the first DB failed.
So, i connected the second DB(DB2) to the "failure" leg of the first (DB1).

ISSUE:
Upon failure of DB1, DB2 would start processing files, but the problem is the file would go to DB1( which has already failed) before going to DB2 & and this is taking much time. My flow is timebound because i should be able to update the DB as fast as possible.
How can i stop DB1 after failure & reroute flow to DB2 automatically. At the moment i am doing it manually and sometimes DB1 goes down in the middle of the night while i am still sleeping.

Thank you for your kind help.

Attached is a depiction of my flow 

 

NiFi Flow.png

1 REPLY 1

avatar
New Contributor

You need to implement some kind of check to see which db is running. 

A small select would do on db1 from nifi - on success set an attribute (pre-added to the file) to db1 on failure update to db2 then the attribute will always have the value of the running db. Both would lead to UpdateAttribute processors then they can lead to the single update using the attribute for the db to connect to.

FYI .. can be a good idea to rename the queues from success and failure to show DB1 and DB2 or whatever makes sense to you.

Hope this helps 🙂