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
Highlighted

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
Highlighted

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.

View solution in original post

2 REPLIES 2
Highlighted

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.

View solution in original post

Highlighted

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

Master Collaborator

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

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven @ DFHZ

Don't have an account?
Coming from Hortonworks? Activate your account here