Actually, I took a stab at this again since I had some spare time now.  I am 
almost done. It looks promising.

The only question I have is about the entity manager.  In the examples, I see 
an entity manager is obtained in the activate method, and used for the rest of 
the life of the component:

        private EntityManager em;

        @Activate
        void init() {
                em = provider.getResource(txControl);
        }


Is this safe in a multi threaded environment? I expect the component to be 
called concurrently. 
Section 127.3.3 of OSGi Companion states that "An Entity Manager is intended to 
be used by a single session, it is not thread safe.” So I am confused since all 
examples seem to be ignoring this.


Best regards,
Alex soto




> On Feb 6, 2019, at 3:16 PM, Tim Jones <t...@mccarthy.co.nz> wrote:
> 
> Hi Alex,
> 
> yes it is possible to use tx-control with Karaf, we have been using it on
> v4.0.5 in our production system for about 18 months with no issues. One of
> the main reasons we use tx-control is that is it 'backed' by a standard.
> Rightly or wrongly we also didn't have confidence in Aries JPA Template at
> the time we were considering transaction managment solutions to manage our
> transactions in a production environment (perhaps this was misguided) but we
> were concerned that there were few integrated tests for that project where
> as there are over 2000 lines of test code for tx-control which demonstrate
> sucess and failure cases for JPA, JDBC, non-XA, XA, last gambit wins,
> commit, rollback depending upon exception type and much more.
> 
> I think the enRoute project has some examples
> https://enroute.osgi.org/examples/023-examples-microservice-jdbc.html and
> the tx-control test code is worth looking at.
> 
> Tim
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Reply via email to