2 Replies Latest reply on May 12, 2009 11:46 AM by beep

    Asynchronous events and transaction

    beep

      Hi,


      I try to use raiseAsynchronousEvent() and handle these events in methods annotated with @Observer. In the observer methods the use of an EntityManager seems to fails for various reasons, which somehow all lead to the problem that the transaction is not propagated to/by the thread which invokes my @Observer. At least this is my assumption.


      The  doucmentation only states this:



      Components may observe asynchronous events in the usual way, but remember that only the business process context is propagated to the asynchronous thread.

      What is in the business process context? Is the transaction included? Is it not? The use of @Transactional with some approriate TransactionPropagationType could help?


      I would appreciate any hints, because I'm currently stuck with it.


      Thanks in advance!

        • 1. Re: Asynchronous events and transaction
          kapitanpetko

          If you are using EJB's, annotate your observer method with @TransactionAttribute(REQUIRES_NEW)
          AFIK, @Transactional does not support REQUIRES_NEW, so this will not work if you are using POJO's.


          The business process context is only relevant if you are using  jBPM, it has nothing to do with transacttion propagation.
          What the docs means is: you can't get to stuff stored in the conversation/session in your observer methods,
          but you have access to stuff stored in the business process context.

          • 2. Re: Asynchronous events and transaction
            beep

            Thanks Nikolay!


            Unfortunatley I'm using POJOs. So, to be able to use transactional Obeserver callbacks I seem to need to switch to EJBs.


            balazs