1

Is it possible to enforce transactionality in a background job from jesque from grails?

I'm using jesque-grails plugin where I can inject other services including GORM ... may I mark the job as @Transaction and expect the payload to be executed in a isolated transaction with rollback on failure?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rafael
  • 2,521
  • 2
  • 33
  • 59

2 Answers2

0

@Transactional works on controllers and services (though it's use on controller actions is not generally recommended). I don't know if it will work on jesque jobs, but it should be pretty easy to find out, i.e. save something, then throw a RuntimeException and see if the saved data is rolled back.

If you can't annotate your method with @Transactional you could instead wrap the method in withTransaction

Dónal
  • 185,044
  • 174
  • 569
  • 824
0

After trying i found the answer is yes. You can simply mark the job as @Transactional and it should work as expected.

Rafael
  • 2,521
  • 2
  • 33
  • 59