Micro
Micro

Reputation: 10891

Questions about objectify's transactionally enqueued tasks

I have some questions about how a transactionally enqueued task works and when it is executed.

Suppose I have some operations in a transaction in this order:

  1. Write an entity
  2. Write another entity
  3. Add work to queue in transaction
  4. Write yet another entity

1) If one of the write entity operations fails, the entire transaction fails. Does that mean no work will be enqueued even if it fails at step 4?

2) When is worked added to the queue if all the write operations succeed? As the final step? Or just in the order it appears?

3) What if adding work to the queue fails, is the entire transaction a failure and all the write operations rolled back?

Upvotes: 0

Views: 77

Answers (1)

stickfigure
stickfigure

Reputation: 13556

1) Yes, if the transaction rolls back no work will be enqueued.

2) Work is added to the queue as part of the transaction commit. When executing, the queued work is guaranteed to see data in the post-transaction state (unless it was otherwise modified, of course).

3) If adding work to the queue fails (and you don't otherwise catch the exception), the exception will propagate up and cause the transaction to rollback.

Upvotes: 1

Related Questions