You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by Charles Moulliard <cm...@gmail.com> on 2011/02/09 15:41:09 UTC

Spring & Aries Tx Manager

Hi,

I have created a project containing a persistence and service layer.
Transactions demarcations are defined at the level of the service like
this

<service ref="incidentService"
interface="org.apache.camel.example.reportincident.service.IncidentService"/>

<bean id="incidentService"
class="org.apache.camel.example.reportincident.service.impl.IncidentServiceImpl">

        <tx:transaction method="*" value="Required" />

        <property name="incidentDAO">
            <reference
interface="org.apache.camel.example.reportincident.dao.IncidentDAO"/>
        </property>

</bean>

Persistence has been defined as presented here after

    <bean id="incidentDAO"
          class="org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl">
        <jpa:context property="entityManager" unitname="ReportIncident"/>
    </bean>

    <service ref="incidentDAO"
             interface="org.apache.camel.example.reportincident.dao.IncidentDAO">
    </service>

>From a Camel transactional route, I commit or generate a rollback in
case of error.

	<!-- SpringTransactionPolicy bean -->
	<bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <property name="transactionManager">
	       <osgi:reference
interface="org.springframework.transaction.PlatformTransactionManager"/>
        </property>
  		<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
	</bean>

        <route>
            <from uri="activemq:queue:in"/>
            <transacted ref="PROPAGATION_REQUIRED"/>
            <doTry>
                <bean ref="incidentSaver" method="process"/>
                <bean ref="generateError" method="generateError"/>
                <doCatch>
                    <exception>java.lang.Exception</exception>
                    <rollback message=">>> Exception generated. We
rollback !!"/>
                </doCatch>
            </doTry>
        </route>

Services exposed :

Apache Aries Transaction Manager (1896) provides:
-------------------------------------------------
org.osgi.service.cm.ManagedServiceFactory
javax.transaction.TransactionManager,
javax.transaction.TransactionSynchronizationRegistry,
javax.transaction.UserTransaction,
org.apache.geronimo.transaction.manager.RecoverableTransactionManager,
org.springframework.transaction.PlatformTransactionManager

Everything works fine as I'm able from my camel route to call the
service layer (=POJO) and insert data in the MySQL DB. Unfortunately,
when I generate an error and a rollback occurs in camel, this one is
not propagated back and data are inserted.

Does anybody has a trick to solve this ?

Regards,

Charles Moulliard

Sr. Principal Solution Architect - FuseSource
Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard

Re: Spring & Aries Tx Manager

Posted by Charles Moulliard <cm...@gmail.com>.
Hi Timothy,

I will change the Tx property --> Mandatory and check what happens in
debug mode.

Regards,

Charles


On Thu, Feb 10, 2011 at 11:04 AM, Timothy Ward <ti...@apache.org> wrote:
>
> Hi Charles,
>
> The <tx:transaction... > element will make use of the javax.transaction.TransactionManager service and will commit any transactions that it begins as soon as the method invocation on the bean completes. If you want the transaction to be created outside the bean you should really be using a MANDATORY transaction type for the bean and debugging why the transaction isn't being started (according to the javax.transaction.TransactionManager) before the service is invoked.
>
> Regards,
>
> Tim
>
> ----------------------------------------
>> Date: Wed, 9 Feb 2011 15:41:09 +0100
>> Subject: Spring & Aries Tx Manager
>> From: cmoulliard@gmail.com
>> To: user@aries.apache.org; dev@aries.apache.org
>>
>> Hi,
>>
>> I have created a project containing a persistence and service layer.
>> Transactions demarcations are defined at the level of the service like
>> this
>>
>>
>> interface="org.apache.camel.example.reportincident.service.IncidentService"/>
>>
>>
>> class="org.apache.camel.example.reportincident.service.impl.IncidentServiceImpl">
>>
>>
>>
>>
>>
>> interface="org.apache.camel.example.reportincident.dao.IncidentDAO"/>
>>
>>
>>
>>
>> Persistence has been defined as presented here after
>>
>>
>> class="org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl">
>>
>>
>>
>>
>> interface="org.apache.camel.example.reportincident.dao.IncidentDAO">
>>
>>
>> From a Camel transactional route, I commit or generate a rollback in
>> case of error.
>>
>>
>>
>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>
>>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> java.lang.Exception
>>
>>
>>
>>
>>
>> Services exposed :
>>
>> Apache Aries Transaction Manager (1896) provides:
>> -------------------------------------------------
>> org.osgi.service.cm.ManagedServiceFactory
>> javax.transaction.TransactionManager,
>> javax.transaction.TransactionSynchronizationRegistry,
>> javax.transaction.UserTransaction,
>> org.apache.geronimo.transaction.manager.RecoverableTransactionManager,
>> org.springframework.transaction.PlatformTransactionManager
>>
>> Everything works fine as I'm able from my camel route to call the
>> service layer (=POJO) and insert data in the MySQL DB. Unfortunately,
>> when I generate an error and a rollback occurs in camel, this one is
>> not propagated back and data are inserted.
>>
>> Does anybody has a trick to solve this ?
>>
>> Regards,
>>
>> Charles Moulliard
>>
>> Sr. Principal Solution Architect - FuseSource
>> Apache Committer
>>
>> Blog : http://cmoulliard.blogspot.com
>> Twitter : http://twitter.com/cmoulliard
>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
>> Skype: cmoulliard
>

Re: Spring & Aries Tx Manager

Posted by Charles Moulliard <cm...@gmail.com>.
Hi Timothy,

I will change the Tx property --> Mandatory and check what happens in
debug mode.

Regards,

Charles


On Thu, Feb 10, 2011 at 11:04 AM, Timothy Ward <ti...@apache.org> wrote:
>
> Hi Charles,
>
> The <tx:transaction... > element will make use of the javax.transaction.TransactionManager service and will commit any transactions that it begins as soon as the method invocation on the bean completes. If you want the transaction to be created outside the bean you should really be using a MANDATORY transaction type for the bean and debugging why the transaction isn't being started (according to the javax.transaction.TransactionManager) before the service is invoked.
>
> Regards,
>
> Tim
>
> ----------------------------------------
>> Date: Wed, 9 Feb 2011 15:41:09 +0100
>> Subject: Spring & Aries Tx Manager
>> From: cmoulliard@gmail.com
>> To: user@aries.apache.org; dev@aries.apache.org
>>
>> Hi,
>>
>> I have created a project containing a persistence and service layer.
>> Transactions demarcations are defined at the level of the service like
>> this
>>
>>
>> interface="org.apache.camel.example.reportincident.service.IncidentService"/>
>>
>>
>> class="org.apache.camel.example.reportincident.service.impl.IncidentServiceImpl">
>>
>>
>>
>>
>>
>> interface="org.apache.camel.example.reportincident.dao.IncidentDAO"/>
>>
>>
>>
>>
>> Persistence has been defined as presented here after
>>
>>
>> class="org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl">
>>
>>
>>
>>
>> interface="org.apache.camel.example.reportincident.dao.IncidentDAO">
>>
>>
>> From a Camel transactional route, I commit or generate a rollback in
>> case of error.
>>
>>
>>
>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>
>>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> java.lang.Exception
>>
>>
>>
>>
>>
>> Services exposed :
>>
>> Apache Aries Transaction Manager (1896) provides:
>> -------------------------------------------------
>> org.osgi.service.cm.ManagedServiceFactory
>> javax.transaction.TransactionManager,
>> javax.transaction.TransactionSynchronizationRegistry,
>> javax.transaction.UserTransaction,
>> org.apache.geronimo.transaction.manager.RecoverableTransactionManager,
>> org.springframework.transaction.PlatformTransactionManager
>>
>> Everything works fine as I'm able from my camel route to call the
>> service layer (=POJO) and insert data in the MySQL DB. Unfortunately,
>> when I generate an error and a rollback occurs in camel, this one is
>> not propagated back and data are inserted.
>>
>> Does anybody has a trick to solve this ?
>>
>> Regards,
>>
>> Charles Moulliard
>>
>> Sr. Principal Solution Architect - FuseSource
>> Apache Committer
>>
>> Blog : http://cmoulliard.blogspot.com
>> Twitter : http://twitter.com/cmoulliard
>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
>> Skype: cmoulliard
>

RE: Spring & Aries Tx Manager

Posted by Timothy Ward <ti...@apache.org>.
Hi Charles,

The <tx:transaction... > element will make use of the javax.transaction.TransactionManager service and will commit any transactions that it begins as soon as the method invocation on the bean completes. If you want the transaction to be created outside the bean you should really be using a MANDATORY transaction type for the bean and debugging why the transaction isn't being started (according to the javax.transaction.TransactionManager) before the service is invoked.

Regards,

Tim

----------------------------------------
> Date: Wed, 9 Feb 2011 15:41:09 +0100
> Subject: Spring & Aries Tx Manager
> From: cmoulliard@gmail.com
> To: user@aries.apache.org; dev@aries.apache.org
>
> Hi,
>
> I have created a project containing a persistence and service layer.
> Transactions demarcations are defined at the level of the service like
> this
>
> 
> interface="org.apache.camel.example.reportincident.service.IncidentService"/>
>
> 
> class="org.apache.camel.example.reportincident.service.impl.IncidentServiceImpl">
>
> 
>
> 
> 
> interface="org.apache.camel.example.reportincident.dao.IncidentDAO"/>
> 
>
> 
>
> Persistence has been defined as presented here after
>
> 
> class="org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl">
> 
> 
>
> 
> interface="org.apache.camel.example.reportincident.dao.IncidentDAO">
> 
>
> From a Camel transactional route, I commit or generate a rollback in
> case of error.
>
> 
> 
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> 
> 
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> 
> 
> 
>
> 
> 
> 
> 
> 
> 
> 
> java.lang.Exception
> 
> 
> 
> 
>
> Services exposed :
>
> Apache Aries Transaction Manager (1896) provides:
> -------------------------------------------------
> org.osgi.service.cm.ManagedServiceFactory
> javax.transaction.TransactionManager,
> javax.transaction.TransactionSynchronizationRegistry,
> javax.transaction.UserTransaction,
> org.apache.geronimo.transaction.manager.RecoverableTransactionManager,
> org.springframework.transaction.PlatformTransactionManager
>
> Everything works fine as I'm able from my camel route to call the
> service layer (=POJO) and insert data in the MySQL DB. Unfortunately,
> when I generate an error and a rollback occurs in camel, this one is
> not propagated back and data are inserted.
>
> Does anybody has a trick to solve this ?
>
> Regards,
>
> Charles Moulliard
>
> Sr. Principal Solution Architect - FuseSource
> Apache Committer
>
> Blog : http://cmoulliard.blogspot.com
> Twitter : http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard
> Skype: cmoulliard
 		 	   		  

RE: Spring & Aries Tx Manager

Posted by Timothy Ward <ti...@apache.org>.
Hi Charles,

The <tx:transaction... > element will make use of the javax.transaction.TransactionManager service and will commit any transactions that it begins as soon as the method invocation on the bean completes. If you want the transaction to be created outside the bean you should really be using a MANDATORY transaction type for the bean and debugging why the transaction isn't being started (according to the javax.transaction.TransactionManager) before the service is invoked.

Regards,

Tim

----------------------------------------
> Date: Wed, 9 Feb 2011 15:41:09 +0100
> Subject: Spring & Aries Tx Manager
> From: cmoulliard@gmail.com
> To: user@aries.apache.org; dev@aries.apache.org
>
> Hi,
>
> I have created a project containing a persistence and service layer.
> Transactions demarcations are defined at the level of the service like
> this
>
> 
> interface="org.apache.camel.example.reportincident.service.IncidentService"/>
>
> 
> class="org.apache.camel.example.reportincident.service.impl.IncidentServiceImpl">
>
> 
>
> 
> 
> interface="org.apache.camel.example.reportincident.dao.IncidentDAO"/>
> 
>
> 
>
> Persistence has been defined as presented here after
>
> 
> class="org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl">
> 
> 
>
> 
> interface="org.apache.camel.example.reportincident.dao.IncidentDAO">
> 
>
> From a Camel transactional route, I commit or generate a rollback in
> case of error.
>
> 
> 
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> 
> 
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> 
> 
> 
>
> 
> 
> 
> 
> 
> 
> 
> java.lang.Exception
> 
> 
> 
> 
>
> Services exposed :
>
> Apache Aries Transaction Manager (1896) provides:
> -------------------------------------------------
> org.osgi.service.cm.ManagedServiceFactory
> javax.transaction.TransactionManager,
> javax.transaction.TransactionSynchronizationRegistry,
> javax.transaction.UserTransaction,
> org.apache.geronimo.transaction.manager.RecoverableTransactionManager,
> org.springframework.transaction.PlatformTransactionManager
>
> Everything works fine as I'm able from my camel route to call the
> service layer (=POJO) and insert data in the MySQL DB. Unfortunately,
> when I generate an error and a rollback occurs in camel, this one is
> not propagated back and data are inserted.
>
> Does anybody has a trick to solve this ?
>
> Regards,
>
> Charles Moulliard
>
> Sr. Principal Solution Architect - FuseSource
> Apache Committer
>
> Blog : http://cmoulliard.blogspot.com
> Twitter : http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard
> Skype: cmoulliard