Re: Single Transaction across EntityManagers
Hello, Have you considered using Aries Transaction Control to manage your transactions? This is a much more reliable way to deal with transactions that run across module boundaries, and it is much clearer which resources have “opted in” to the transaction. Best Regards, Tim On 1 Jun 2018, at 06:39, Mohideen, Kaja (Nokia - IN/Chennai) mailto:kaja.mohid...@nokia.com>> wrote: Hi, I’m using Aries JPA (in Apache Karaf) for my application where different services (bundles) have their own PersistenceContexts and they use a single Datasource (XA) – everything works fine. All my modules are connecting to a single Datasource, so I have switched to Non-XA DS; now the Transactions seems to be per module (EM) and they are not atomic across modules. I understand that XA would have co-ordinated this earlier. But, is it possible to make them use a Single DS Connection/Transaction to achieve the same effect (like mark PersistenceUnits “extended” or some other technique). I have searched the Aries-JPA repo for mention of PersistenceContextType and found nothing ☹. So, not sure whether Aries JPA supports this and if so – how? Any help is greatly appreciated. // Kaja
RE: Single Transaction across EntityManagers
Hi Tim, Thanks for responding. I have seen TX Control Project in Aries website. But, that will need my code to explicit to do this TX management. I don’t have a case where I want one of my bundles have their “own” TX. If there is one TX in a thread and if that thread happens to go across boundaries, they have to use the same TX. So, I’m looking to make it tied with Std TX annotations. Other option I can think of: A bundle with a PU and service (So, 1 PU for all my apps). All my other application bundles invoke the service to get their entities register with EMF. But, I’m not sure whether Aries allowes Entities to be added/deleted (I don’t want updated case to be supported) after EMF is created. Any idea? // Kaja From: Timothy Ward [mailto:timothyjw...@hotmail.com] On Behalf Of Timothy Ward Sent: Tuesday, June 5, 2018 4:13 PM To: user@aries.apache.org Subject: Re: Single Transaction across EntityManagers Importance: High Hello, Have you considered using Aries Transaction Control to manage your transactions? This is a much more reliable way to deal with transactions that run across module boundaries, and it is much clearer which resources have “opted in” to the transaction. Best Regards, Tim On 1 Jun 2018, at 06:39, Mohideen, Kaja (Nokia - IN/Chennai) mailto:kaja.mohid...@nokia.com>> wrote: Hi, I’m using Aries JPA (in Apache Karaf) for my application where different services (bundles) have their own PersistenceContexts and they use a single Datasource (XA) – everything works fine. All my modules are connecting to a single Datasource, so I have switched to Non-XA DS; now the Transactions seems to be per module (EM) and they are not atomic across modules. I understand that XA would have co-ordinated this earlier. But, is it possible to make them use a Single DS Connection/Transaction to achieve the same effect (like mark PersistenceUnits “extended” or some other technique). I have searched the Aries-JPA repo for mention of PersistenceContextType and found nothing ☹. So, not sure whether Aries JPA supports this and if so – how? Any help is greatly appreciated. // Kaja
Re: Single Transaction across EntityManagers
Hi Kaja, If there is one TX in a thread and if that thread happens to go across boundaries, they have to use the same TX. This is exactly what Transaction Control does if you use the required method. Also your use case definitely requires you to use XA transactions. You have multiple persistence units therefore you have multiple database connections (even if they are to the same database) and so you require a distributed transaction. I’m not sure whether Aries allowes Entities to be added/deleted (I don’t want updated case to be supported) after EMF is created. Any idea? This is not supported at runtimeby JPA, so there’s nothing Aries (or OSGi) can do to help beyond uninstalling the old bundle and installing the new bundle. Regards, Tim On 5 Jun 2018, at 12:02, Mohideen, Kaja (Nokia - IN/Chennai) mailto:kaja.mohid...@nokia.com>> wrote: Hi Tim, Thanks for responding. I have seen TX Control Project in Aries website. But, that will need my code to explicit to do this TX management. I don’t have a case where I want one of my bundles have their “own” TX. If there is one TX in a thread and if that thread happens to go across boundaries, they have to use the same TX. So, I’m looking to make it tied with Std TX annotations. Other option I can think of: A bundle with a PU and service (So, 1 PU for all my apps). All my other application bundles invoke the service to get their entities register with EMF. But, I’m not sure whether Aries allowes Entities to be added/deleted (I don’t want updated case to be supported) after EMF is created. Any idea? // Kaja From: Timothy Ward [mailto:timothyjw...@hotmail.com] On Behalf Of Timothy Ward Sent: Tuesday, June 5, 2018 4:13 PM To: user@aries.apache.org<mailto:user@aries.apache.org> Subject: Re: Single Transaction across EntityManagers Importance: High Hello, Have you considered using Aries Transaction Control to manage your transactions? This is a much more reliable way to deal with transactions that run across module boundaries, and it is much clearer which resources have “opted in” to the transaction. Best Regards, Tim On 1 Jun 2018, at 06:39, Mohideen, Kaja (Nokia - IN/Chennai) mailto:kaja.mohid...@nokia.com>> wrote: Hi, I’m using Aries JPA (in Apache Karaf) for my application where different services (bundles) have their own PersistenceContexts and they use a single Datasource (XA) – everything works fine. All my modules are connecting to a single Datasource, so I have switched to Non-XA DS; now the Transactions seems to be per module (EM) and they are not atomic across modules. I understand that XA would have co-ordinated this earlier. But, is it possible to make them use a Single DS Connection/Transaction to achieve the same effect (like mark PersistenceUnits “extended” or some other technique). I have searched the Aries-JPA repo for mention of PersistenceContextType and found nothing ☹. So, not sure whether Aries JPA supports this and if so – how? Any help is greatly appreciated. // Kaja