Hi,

On 5 November 2014 13:05, jbrook <[email protected]> wrote:

> I am currently using the Doctrine postFlush and onFlush lifecycle events
> to index entities that are saved to an external search server. The onFlush
> handler is used to grab the insertions, updates and deletes from the
> UnitOfWork and the the postFlush handler is used to broadcast
> representations of the changed entities to the external system.
>
> Recently we introduced some code which sometimes causes the surrounding
> transaction to be rolled back. However the events are still triggered and
> we end up with information on the external search server which should not
> be there because it was never actually committed to the database.
>
> I would really appreciate it if someone had some advice on how to handle
> this situation. Is there a way to detect a rollback in postFlush? Or
> perhaps there is a better architecture I should consider for synchronising
> the CRUD operations with the external system.
>

You cannot use `postFlush` to detect rollbacks, as exceptions causing
rollbacks bubble up, and `postFlush` is never called in those cases.

See the code directly for reference:
https://github.com/doctrine/doctrine2/blob/20c6bfd360b3db9e9bc53e5ae37afe1a22dccca3/lib/Doctrine/ORM/UnitOfWork.php#L398


Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to