Support Questions

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

How to mantain order of sql statement executions after RouteOnAttribute?

avatar
New Contributor

Dear community,

I'm creating a proof of concept where I consume messages (JSON) from a kafka topic related to crud operations of a resource. Then, I execute those opperations on a Postgres database.

I've uploaded an image describing what I've done. Depending on an "action" field of JSON, I route it to different processor groups that execute those sql statements.

My problem is that I need to maintain order, i.e. if I have an update after an insert I need to ensure that insert will be executed before the update.

I've played with wait and notify but didn't reach a reasonable solution.

Any suggestion? Is nifi the right tool for this kind of problems?

Thanks in advance


nifi.png
1 ACCEPTED SOLUTION

avatar
New Contributor

I solved it using PutDatabaseRecord. First I load the attribute statement.type with EvaluateJsonPath and then use JsonPathReader as the PutDatabaseRecord reader service, using that statement.type attribute to switch between operations.
If someone have the same problem and needs me to explain it further don't hesitate to ask.

View solution in original post

2 REPLIES 2

avatar
New Contributor

I solved it using PutDatabaseRecord. First I load the attribute statement.type with EvaluateJsonPath and then use JsonPathReader as the PutDatabaseRecord reader service, using that statement.type attribute to switch between operations.
If someone have the same problem and needs me to explain it further don't hesitate to ask.

avatar
Super Guru

@Errico Malatesta good job, glad you were able to work it out!