playframework / play1

Play framework
https://www.playframework.com/documentation/1.4.x/home
Other
1.58k stars 682 forks source link

New method "afterInvocation" similar to "afterRequest" but also works on jobs #1495

Open amartins27 opened 1 month ago

amartins27 commented 1 month ago

Is your feature request related to a problem? Please describe. Is there any reason why the afterRequest method was implemented just for requests and not for jobs?

Describe the solution you'd like I would like to launch jobs once the current jobs is finished, to make sure the transaction is commited before the next jobs start.

cies commented 1 month ago

We stopped using Play1's job runner as it did not have a proper queue'ing system. Now we use a self-rolled jobs system that is AWS/SQS backed. Simple, persisted, scalable. Our crons are in AWS/CloudWatch (crons are infra for us).

We use RePlay now by the way, but we already started using this new system when we were still on Play1.

amartins27 commented 1 month ago

I see a lot of things that are great about RePlay, will definitly have that in mind. Instead of jobs you are using SQS messages and then several consumers? How do you handle order in that case?

The issue I'm having is that I'm creating entities in JobA, that entity triggers JobB on @PostPersist. Then on JobB I'm getting session errors because the transaction on JobA is still not commited... This does not happen in a request context because of afterRequest. Changing that method to also consider job context does works, but I'm not sure if changing this has other implications.