You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by cnicolai <cr...@gmail.com> on 2007/03/27 23:11:55 UTC

ServiceMix transaction sync between spring, components and Jboss

Hi guys,


I'm trying to syncronize Spring DAO's transaction and ServiceMix components,
everything works fine, i'm using a custom jboss-deployer where i load an jbi
container from a Spring Xml. The version from  ServiceMix is 3.1. My problem
is that when an Exception occurs during the processing of an exchange
(onMessageExchange) from a component, the spring transaction is commited in
the database.
To control the transacion manager i configure this in the container: 


<bean id="transactionManager"
class="org.springframework.jndi.JndiObjectFactoryBean"> 
		<property name="jndiName"> 
			<value>java:/TransactionManager</value> 
		</property> 
	</bean>

<sm:container id="jbi" rootDir="./data/ServiceMix" useShutdownHook="false"
transactionManager="#transactionManager" autoEnlistInTransaction="true" 
monitorInstallationDirectory="false" createJmxConnector="false"
useMBeanServer="true" createMBeanServer="false">

<sm:flows>
			<sm:jcaFlow jmsURL="tcp://localhost:61616" />
			<sm:sedaFlow />			
		</sm:flows>

And this in my app:

<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
		<property name="transactionManagerName" value="java:/TransactionManager"/>
		<property name="userTransactionName" value="UserTransaction"/>
	</bean>
	
	<bean name="transactionProxy"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
		<property name="transactionManager"><ref
local="transactionManager"/></property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>


Someone knows what i doing wrong??
-- 
View this message in context: http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9701134
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix transaction sync between spring, components and Jboss

Posted by Guillaume Nodet <gn...@gmail.com>.
I think there is room for some small error handling components
which could be put in the EIP components:
  * mark the transaction as rollback only if an error occurs
  * re-route if an error occurs
 and more ...

Else, you can configure an MessageExchangeListener
(org.apache.servicemix.jbi.events pacakge) to intercept
all exchanges and mark the transaction as rollback only
at this point.

On 3/28/07, cnicolai <cr...@gmail.com> wrote:
>
>
> I saw this components ProxyInOutBinding and ProxyInOnlyBinding...can be my
> solution?
>
> How i use them?
>
> Thanks.
>
>
> cnicolai wrote:
> >
> >
> > I made a test with your suggestion and worked....
> >
> > TransactionManager tm = (TransactionManager)
> > getContext().getTransactionManager();
> > tm.setRollbackOnly();
> >
> > But how i can intercept, like a proxy, to handle this without repeat
> this
> > code in every component?
> >
> >
> > cnicolai wrote:
> >>
> >> I`m using some customized components that extends FillePoller,
> >> TransformComponentSupport, ComponentSupport....
> >> But the container or the flow (jca) don`t do this when the precessing
> of
> >> an exchange fail??
> >> Which is the behavior when this occur...?
> >>
> >>
> >> gnodet wrote:
> >>>
> >>> The component has to set the rollback only flag on the transaction.
> >>> Which component do you use ?
> >>>
> >>> On 3/27/07, cnicolai <cr...@gmail.com> wrote:
> >>>>
> >>>>
> >>>> Hi guys,
> >>>>
> >>>>
> >>>> I'm trying to syncronize Spring DAO's transaction and ServiceMix
> >>>> components,
> >>>> everything works fine, i'm using a custom jboss-deployer where i load
> >>>> an
> >>>> jbi
> >>>> container from a Spring Xml. The version from  ServiceMix is 3.1. My
> >>>> problem
> >>>> is that when an Exception occurs during the processing of an exchange
> >>>> (onMessageExchange) from a component, the spring transaction is
> >>>> commited
> >>>> in
> >>>> the database.
> >>>> To control the transacion manager i configure this in the container:
> >>>>
> >>>>
> >>>> <bean id="transactionManager"
> >>>> class="org.springframework.jndi.JndiObjectFactoryBean">
> >>>>                 <property name="jndiName">
> >>>>                         <value>java:/TransactionManager</value>
> >>>>                 </property>
> >>>>         </bean>
> >>>>
> >>>> <sm:container id="jbi" rootDir="./data/ServiceMix"
> >>>> useShutdownHook="false"
> >>>> transactionManager="#transactionManager"
> autoEnlistInTransaction="true"
> >>>> monitorInstallationDirectory="false" createJmxConnector="false"
> >>>> useMBeanServer="true" createMBeanServer="false">
> >>>>
> >>>> <sm:flows>
> >>>>                         <sm:jcaFlow jmsURL="tcp://localhost:61616" />
> >>>>                         <sm:sedaFlow />
> >>>>                 </sm:flows>
> >>>>
> >>>> And this in my app:
> >>>>
> >>>> <bean id="transactionManager"
> >>>> class="org.springframework.transaction.jta.JtaTransactionManager">
> >>>>                 <property name="transactionManagerName"
> >>>> value="java:/TransactionManager"/>
> >>>>                 <property name="userTransactionName"
> >>>> value="UserTransaction"/>
> >>>>         </bean>
> >>>>
> >>>>         <bean name="transactionProxy"
> >>>> class="
> org.springframework.transaction.interceptor.TransactionInterceptor
> >>>> ">
> >>>>                 <property name="transactionManager"><ref
> >>>> local="transactionManager"/></property>
> >>>>                 <property name="transactionAttributes">
> >>>>                         <props>
> >>>>                                 <prop
> >>>> key="*">PROPAGATION_REQUIRED</prop>
> >>>>                         </props>
> >>>>                 </property>
> >>>>         </bean>
> >>>>
> >>>>
> >>>> Someone knows what i doing wrong??
> >>>> --
> >>>> View this message in context:
> >>>>
> http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9701134
> >>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> Cheers,
> >>> Guillaume Nodet
> >>> ------------------------
> >>> Architect, LogicBlaze (http://www.logicblaze.com/)
> >>> Blog: http://gnodet.blogspot.com/
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9718382
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Architect, LogicBlaze (http://www.logicblaze.com/)
Blog: http://gnodet.blogspot.com/

Re: ServiceMix transaction sync between spring, components and Jboss

Posted by cnicolai <cr...@gmail.com>.
I saw this components ProxyInOutBinding and ProxyInOnlyBinding...can be my
solution?

How i use them?

Thanks.


cnicolai wrote:
> 
> 
> I made a test with your suggestion and worked....
> 
> TransactionManager tm = (TransactionManager)
> getContext().getTransactionManager();
> tm.setRollbackOnly();
> 
> But how i can intercept, like a proxy, to handle this without repeat this
> code in every component?
> 
> 
> cnicolai wrote:
>> 
>> I`m using some customized components that extends FillePoller,
>> TransformComponentSupport, ComponentSupport.... 
>> But the container or the flow (jca) don`t do this when the precessing of
>> an exchange fail??
>> Which is the behavior when this occur...?
>> 
>> 
>> gnodet wrote:
>>> 
>>> The component has to set the rollback only flag on the transaction.
>>> Which component do you use ?
>>> 
>>> On 3/27/07, cnicolai <cr...@gmail.com> wrote:
>>>>
>>>>
>>>> Hi guys,
>>>>
>>>>
>>>> I'm trying to syncronize Spring DAO's transaction and ServiceMix
>>>> components,
>>>> everything works fine, i'm using a custom jboss-deployer where i load
>>>> an
>>>> jbi
>>>> container from a Spring Xml. The version from  ServiceMix is 3.1. My
>>>> problem
>>>> is that when an Exception occurs during the processing of an exchange
>>>> (onMessageExchange) from a component, the spring transaction is
>>>> commited
>>>> in
>>>> the database.
>>>> To control the transacion manager i configure this in the container:
>>>>
>>>>
>>>> <bean id="transactionManager"
>>>> class="org.springframework.jndi.JndiObjectFactoryBean">
>>>>                 <property name="jndiName">
>>>>                         <value>java:/TransactionManager</value>
>>>>                 </property>
>>>>         </bean>
>>>>
>>>> <sm:container id="jbi" rootDir="./data/ServiceMix"
>>>> useShutdownHook="false"
>>>> transactionManager="#transactionManager" autoEnlistInTransaction="true"
>>>> monitorInstallationDirectory="false" createJmxConnector="false"
>>>> useMBeanServer="true" createMBeanServer="false">
>>>>
>>>> <sm:flows>
>>>>                         <sm:jcaFlow jmsURL="tcp://localhost:61616" />
>>>>                         <sm:sedaFlow />
>>>>                 </sm:flows>
>>>>
>>>> And this in my app:
>>>>
>>>> <bean id="transactionManager"
>>>> class="org.springframework.transaction.jta.JtaTransactionManager">
>>>>                 <property name="transactionManagerName"
>>>> value="java:/TransactionManager"/>
>>>>                 <property name="userTransactionName"
>>>> value="UserTransaction"/>
>>>>         </bean>
>>>>
>>>>         <bean name="transactionProxy"
>>>> class="org.springframework.transaction.interceptor.TransactionInterceptor
>>>> ">
>>>>                 <property name="transactionManager"><ref
>>>> local="transactionManager"/></property>
>>>>                 <property name="transactionAttributes">
>>>>                         <props>
>>>>                                 <prop
>>>> key="*">PROPAGATION_REQUIRED</prop>
>>>>                         </props>
>>>>                 </property>
>>>>         </bean>
>>>>
>>>>
>>>> Someone knows what i doing wrong??
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9701134
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>> 
>>> 
>>> -- 
>>> Cheers,
>>> Guillaume Nodet
>>> ------------------------
>>> Architect, LogicBlaze (http://www.logicblaze.com/)
>>> Blog: http://gnodet.blogspot.com/
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9718382
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix transaction sync between spring, components and Jboss

Posted by cnicolai <cr...@gmail.com>.

I made a test with your suggestion and worked....

TransactionManager tm = (TransactionManager)
getContext().getTransactionManager();
tm.setRollbackOnly();

But how i can intercept, like a proxy, to handle this without repeat this
code in every component?


cnicolai wrote:
> 
> I`m using some customized components that extends FillePoller,
> TransformComponentSupport, ComponentSupport.... 
> But the container or the flow (jca) don`t do this when the precessing of
> an exchange fail??
> Which is the behavior when this occur...?
> 
> 
> gnodet wrote:
>> 
>> The component has to set the rollback only flag on the transaction.
>> Which component do you use ?
>> 
>> On 3/27/07, cnicolai <cr...@gmail.com> wrote:
>>>
>>>
>>> Hi guys,
>>>
>>>
>>> I'm trying to syncronize Spring DAO's transaction and ServiceMix
>>> components,
>>> everything works fine, i'm using a custom jboss-deployer where i load an
>>> jbi
>>> container from a Spring Xml. The version from  ServiceMix is 3.1. My
>>> problem
>>> is that when an Exception occurs during the processing of an exchange
>>> (onMessageExchange) from a component, the spring transaction is commited
>>> in
>>> the database.
>>> To control the transacion manager i configure this in the container:
>>>
>>>
>>> <bean id="transactionManager"
>>> class="org.springframework.jndi.JndiObjectFactoryBean">
>>>                 <property name="jndiName">
>>>                         <value>java:/TransactionManager</value>
>>>                 </property>
>>>         </bean>
>>>
>>> <sm:container id="jbi" rootDir="./data/ServiceMix"
>>> useShutdownHook="false"
>>> transactionManager="#transactionManager" autoEnlistInTransaction="true"
>>> monitorInstallationDirectory="false" createJmxConnector="false"
>>> useMBeanServer="true" createMBeanServer="false">
>>>
>>> <sm:flows>
>>>                         <sm:jcaFlow jmsURL="tcp://localhost:61616" />
>>>                         <sm:sedaFlow />
>>>                 </sm:flows>
>>>
>>> And this in my app:
>>>
>>> <bean id="transactionManager"
>>> class="org.springframework.transaction.jta.JtaTransactionManager">
>>>                 <property name="transactionManagerName"
>>> value="java:/TransactionManager"/>
>>>                 <property name="userTransactionName"
>>> value="UserTransaction"/>
>>>         </bean>
>>>
>>>         <bean name="transactionProxy"
>>> class="org.springframework.transaction.interceptor.TransactionInterceptor
>>> ">
>>>                 <property name="transactionManager"><ref
>>> local="transactionManager"/></property>
>>>                 <property name="transactionAttributes">
>>>                         <props>
>>>                                 <prop
>>> key="*">PROPAGATION_REQUIRED</prop>
>>>                         </props>
>>>                 </property>
>>>         </bean>
>>>
>>>
>>> Someone knows what i doing wrong??
>>> --
>>> View this message in context:
>>> http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9701134
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> -- 
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Architect, LogicBlaze (http://www.logicblaze.com/)
>> Blog: http://gnodet.blogspot.com/
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9718375
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix transaction sync between spring, components and Jboss

Posted by cnicolai <cr...@gmail.com>.
I`m using some customized components that extends FillePoller,
TransformComponentSupport, ComponentSupport.... 
But the container or the flow (jca) don`t do this when the precessing of an
exchange fail??
Which is the behavior when this occur...?


gnodet wrote:
> 
> The component has to set the rollback only flag on the transaction.
> Which component do you use ?
> 
> On 3/27/07, cnicolai <cr...@gmail.com> wrote:
>>
>>
>> Hi guys,
>>
>>
>> I'm trying to syncronize Spring DAO's transaction and ServiceMix
>> components,
>> everything works fine, i'm using a custom jboss-deployer where i load an
>> jbi
>> container from a Spring Xml. The version from  ServiceMix is 3.1. My
>> problem
>> is that when an Exception occurs during the processing of an exchange
>> (onMessageExchange) from a component, the spring transaction is commited
>> in
>> the database.
>> To control the transacion manager i configure this in the container:
>>
>>
>> <bean id="transactionManager"
>> class="org.springframework.jndi.JndiObjectFactoryBean">
>>                 <property name="jndiName">
>>                         <value>java:/TransactionManager</value>
>>                 </property>
>>         </bean>
>>
>> <sm:container id="jbi" rootDir="./data/ServiceMix"
>> useShutdownHook="false"
>> transactionManager="#transactionManager" autoEnlistInTransaction="true"
>> monitorInstallationDirectory="false" createJmxConnector="false"
>> useMBeanServer="true" createMBeanServer="false">
>>
>> <sm:flows>
>>                         <sm:jcaFlow jmsURL="tcp://localhost:61616" />
>>                         <sm:sedaFlow />
>>                 </sm:flows>
>>
>> And this in my app:
>>
>> <bean id="transactionManager"
>> class="org.springframework.transaction.jta.JtaTransactionManager">
>>                 <property name="transactionManagerName"
>> value="java:/TransactionManager"/>
>>                 <property name="userTransactionName"
>> value="UserTransaction"/>
>>         </bean>
>>
>>         <bean name="transactionProxy"
>> class="org.springframework.transaction.interceptor.TransactionInterceptor
>> ">
>>                 <property name="transactionManager"><ref
>> local="transactionManager"/></property>
>>                 <property name="transactionAttributes">
>>                         <props>
>>                                 <prop key="*">PROPAGATION_REQUIRED</prop>
>>                         </props>
>>                 </property>
>>         </bean>
>>
>>
>> Someone knows what i doing wrong??
>> --
>> View this message in context:
>> http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9701134
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Architect, LogicBlaze (http://www.logicblaze.com/)
> Blog: http://gnodet.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9714859
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix transaction sync between spring, components and Jboss

Posted by Guillaume Nodet <gn...@gmail.com>.
The component has to set the rollback only flag on the transaction.
Which component do you use ?

On 3/27/07, cnicolai <cr...@gmail.com> wrote:
>
>
> Hi guys,
>
>
> I'm trying to syncronize Spring DAO's transaction and ServiceMix
> components,
> everything works fine, i'm using a custom jboss-deployer where i load an
> jbi
> container from a Spring Xml. The version from  ServiceMix is 3.1. My
> problem
> is that when an Exception occurs during the processing of an exchange
> (onMessageExchange) from a component, the spring transaction is commited
> in
> the database.
> To control the transacion manager i configure this in the container:
>
>
> <bean id="transactionManager"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>                 <property name="jndiName">
>                         <value>java:/TransactionManager</value>
>                 </property>
>         </bean>
>
> <sm:container id="jbi" rootDir="./data/ServiceMix" useShutdownHook="false"
> transactionManager="#transactionManager" autoEnlistInTransaction="true"
> monitorInstallationDirectory="false" createJmxConnector="false"
> useMBeanServer="true" createMBeanServer="false">
>
> <sm:flows>
>                         <sm:jcaFlow jmsURL="tcp://localhost:61616" />
>                         <sm:sedaFlow />
>                 </sm:flows>
>
> And this in my app:
>
> <bean id="transactionManager"
> class="org.springframework.transaction.jta.JtaTransactionManager">
>                 <property name="transactionManagerName"
> value="java:/TransactionManager"/>
>                 <property name="userTransactionName"
> value="UserTransaction"/>
>         </bean>
>
>         <bean name="transactionProxy"
> class="org.springframework.transaction.interceptor.TransactionInterceptor
> ">
>                 <property name="transactionManager"><ref
> local="transactionManager"/></property>
>                 <property name="transactionAttributes">
>                         <props>
>                                 <prop key="*">PROPAGATION_REQUIRED</prop>
>                         </props>
>                 </property>
>         </bean>
>
>
> Someone knows what i doing wrong??
> --
> View this message in context:
> http://www.nabble.com/ServiceMix-transaction-sync-between-spring%2C-components-and-Jboss-tf3475627s12049.html#a9701134
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Architect, LogicBlaze (http://www.logicblaze.com/)
Blog: http://gnodet.blogspot.com/