Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to mantain order of sql statement executions after RouteOnAttribute?

Solved Go to solution

How to mantain order of sql statement executions after RouteOnAttribute?

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

Accepted Solutions

Re: How to mantain order of sql statement executions after RouteOnAttribute?

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.

2 REPLIES 2

Re: How to mantain order of sql statement executions after RouteOnAttribute?

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.

Re: How to mantain order of sql statement executions after RouteOnAttribute?

Expert Contributor

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