Quantcast

Error using Transacted with Camel 2.0

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error using Transacted with Camel 2.0

Charles Moulliard
Camel generates the following error with my route :

Route

        <camel:route>
            <camel:from ref="queueQuickFixInEndpoint" />
            <camel:convertBodyTo type="quickfix.Message" />
            <camel:transacted/>
            <camel:bean ref="serviceHelper" method="createNotification" />
            <camel:bean ref="serviceHelper" method="generateError" />
            <camel:to ref="directNotificationEndpoint" />
        </camel:route>

It seems that policy must be defined but in the example here it is not
mentioned : http://camel.apache.org/transactional-client.html

Error :

15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener            |
BundleApplicationContextListener   50 | Application context refresh failed
(OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
config=osgibundle:/META-INF/spring/*.xml))
org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException:
policy must be specified on: Transacted[ref: null]
    at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
    at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
    at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
    at
org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
    at
org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
    at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
    at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
    at
org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
    at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
    at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
    at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: policy must be specified on:
Transacted[ref: null]
    at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
    at
org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
    at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
    at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
    at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
    at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
    at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
    at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
    at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
    at
org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
    at
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
    at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
    at
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
    at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
Does not work too if I had

            <camel:policy ref="PROPAGATION_REQUIRED" />

in the route

karaf@root:osgi> Exception in thread "SpringOsgiExtenderThread-32"
org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException:
policy
must be specified on: Policy[ref: PROPAGATION_REQUIRED]
        at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
        at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
        at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
        at
org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
        at
org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
        at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
        at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
        at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
        at
org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.ja
va:358)

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard <[hidden email]>wrote:

> Camel generates the following error with my route :
>
> Route
>
>         <camel:route>
>             <camel:from ref="queueQuickFixInEndpoint" />
>             <camel:convertBodyTo type="quickfix.Message" />
>             <camel:transacted/>
>             <camel:bean ref="serviceHelper" method="createNotification" />
>             <camel:bean ref="serviceHelper" method="generateError" />
>             <camel:to ref="directNotificationEndpoint" />
>         </camel:route>
>
> It seems that policy must be defined but in the example here it is not
> mentioned : http://camel.apache.org/transactional-client.html
>
> Error :
>
> 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
> | BundleApplicationContextListener   50 | Application context refresh failed
> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> config=osgibundle:/META-INF/spring/*.xml))
> org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException:
> policy must be specified on: Transacted[ref: null]
>     at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>     at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>     at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>     at
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>     at
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>     at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>     at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>     at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>     at
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>     at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>     at
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>     at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>     at
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>     at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.IllegalArgumentException: policy must be specified on:
> Transacted[ref: null]
>     at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>     at
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>     at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>     at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>     at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>     at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>     at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>     at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>     at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>     at
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>     at
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>     at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>     at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>     at
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>     at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Claus Ibsen-2
In reply to this post by Charles Moulliard
Hi

Yeah you need to add all the spring transaction stuff.


On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<[hidden email]> wrote:

> Camel generates the following error with my route :
>
> Route
>
>        <camel:route>
>            <camel:from ref="queueQuickFixInEndpoint" />
>            <camel:convertBodyTo type="quickfix.Message" />
>            <camel:transacted/>
>            <camel:bean ref="serviceHelper" method="createNotification" />
>            <camel:bean ref="serviceHelper" method="generateError" />
>            <camel:to ref="directNotificationEndpoint" />
>        </camel:route>
>
> It seems that policy must be defined but in the example here it is not
> mentioned : http://camel.apache.org/transactional-client.html
>
> Error :
>
> 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener            |
> BundleApplicationContextListener   50 | Application context refresh failed
> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> config=osgibundle:/META-INF/spring/*.xml))
> org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException:
> policy must be specified on: Transacted[ref: null]
>    at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>    at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>    at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>    at
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>    at
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>    at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>    at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>    at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>    at
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>    at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>    at
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>    at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>    at
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>    at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.IllegalArgumentException: policy must be specified on:
> Transacted[ref: null]
>    at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>    at
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>    at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>    at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>    at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>    at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>    at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>    at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>    at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>    at
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>    at
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>    at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>    at
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>    at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
When I compare the example : JMSTransactionalClientRollbackTest.xml

    <!-- START SNIPPET: e1 -->
    <!-- setup JMS connection factory -->
    <bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL"
value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
    </bean>

    <!-- setup spring jms TX manager -->
    <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
    </bean>

    <!-- define our activemq component -->
    <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
        <!-- define the jms consumer/producer as transacted -->
        <property name="transacted" value="true"/>
        <!-- setup the transaction manager to use -->
        <!-- if not provided then Camel will automatic use a
JmsTransactionManager, however if you
             for instance use a JTA transaction manager then you must
configure it -->
        <property name="transactionManager" ref="jmsTransactionManager"/>
    </bean>
    <!-- END SNIPPET: e1 -->

    <!-- START SNIPPET: e2 -->
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <!-- 1: from the jms queue -->
            <from uri="activemq:queue:okay"/>
            <!-- 2: mark this route as transacted -->
            <transacted/>
            <!-- 3: call our business logic that is myProcessor -->
            <process ref="myProcessor"/>
            <!-- 4: if success then send it to the mock -->
            <to uri="mock:result"/>
        </route>
    </camelContext>

with mine.

What is different concerns the TransactionManager used.

In the example, this is the Spring one:

    <!-- setup spring jms TX manager -->
    <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
    </bean>

and in my case, ActiveMQ is configured to use Geronimo Transaction Manager
bundle (which in fact uses spring Transaction manager :
org.springframework.transaction.jta.JtaTransactionManager;)

I suppose that in the example, the policy is defined by default by spring
when instantiating the class :
org.springframework.jms.connection.JmsTransactionManager

Is it possible to do the same using a JtaTransaction manager ?

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]> wrote:

> Hi
>
> Yeah you need to add all the spring transaction stuff.
>
>
> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<[hidden email]>
> wrote:
> > Camel generates the following error with my route :
> >
> > Route
> >
> >        <camel:route>
> >            <camel:from ref="queueQuickFixInEndpoint" />
> >            <camel:convertBodyTo type="quickfix.Message" />
> >            <camel:transacted/>
> >            <camel:bean ref="serviceHelper" method="createNotification" />
> >            <camel:bean ref="serviceHelper" method="generateError" />
> >            <camel:to ref="directNotificationEndpoint" />
> >        </camel:route>
> >
> > It seems that policy must be defined but in the example here it is not
> > mentioned : http://camel.apache.org/transactional-client.html
> >
> > Error :
> >
> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
>  |
> > BundleApplicationContextListener   50 | Application context refresh
> failed
> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> > config=osgibundle:/META-INF/spring/*.xml))
> > org.apache.camel.RuntimeCamelException:
> java.lang.IllegalArgumentException:
> > policy must be specified on: Transacted[ref: null]
> >    at
> >
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
> >    at
> >
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
> >    at
> >
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
> >    at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
> >    at
> >
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> >    at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
> >    at
> >
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
> >    at
> >
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
> >    at
> >
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
> >    at
> >
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
> >    at
> >
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> >    at
> >
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> >    at
> >
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
> >    at java.lang.Thread.run(Thread.java:619)
> > Caused by: java.lang.IllegalArgumentException: policy must be specified
> on:
> > Transacted[ref: null]
> >    at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
> >    at
> >
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
> >    at
> >
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
> >    at
> >
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
> >    at
> >
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
> >    at
> >
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
> >    at
> >
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
> >    at
> >
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
> >    at
> >
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
> >    at
> >
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
> >    at
> >
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
> >    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
> >    at
> >
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
> >    at
> >
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
> >    at
> >
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
I have been able to solve my problem by adding the following bean definition
:

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

and in the route

        <camel:route>
            <camel:from ref="queueQuickFixInEndpoint" />
            <camel:convertBodyTo type="quickfix.Message" />
            <camel:transacted/>
            <camel:policy ref="required" />
            <camel:bean ref="serviceHelper" method="createNotification" />
            <camel:bean ref="serviceHelper" method="generateError" />
            <camel:to ref="directNotificationEndpoint" />
        </camel:route>

Unfortunately, the rollback does not occur in the DB and 6 records have been
created by the method createNotification when error has been raised by the
method generateError.

What is missing ?

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <[hidden email]>wrote:

> When I compare the example : JMSTransactionalClientRollbackTest.xml
>
>     <!-- START SNIPPET: e1 -->
>     <!-- setup JMS connection factory -->
>     <bean id="jmsConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL"
> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>     </bean>
>
>     <!-- setup spring jms TX manager -->
>     <bean id="jmsTransactionManager"
> class="org.springframework.jms.connection.JmsTransactionManager">
>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>     </bean>
>
>     <!-- define our activemq component -->
>     <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>         <!-- define the jms consumer/producer as transacted -->
>         <property name="transacted" value="true"/>
>         <!-- setup the transaction manager to use -->
>         <!-- if not provided then Camel will automatic use a
> JmsTransactionManager, however if you
>              for instance use a JTA transaction manager then you must
> configure it -->
>         <property name="transactionManager" ref="jmsTransactionManager"/>
>     </bean>
>     <!-- END SNIPPET: e1 -->
>
>     <!-- START SNIPPET: e2 -->
>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>         <route>
>             <!-- 1: from the jms queue -->
>             <from uri="activemq:queue:okay"/>
>             <!-- 2: mark this route as transacted -->
>             <transacted/>
>             <!-- 3: call our business logic that is myProcessor -->
>             <process ref="myProcessor"/>
>             <!-- 4: if success then send it to the mock -->
>             <to uri="mock:result"/>
>         </route>
>     </camelContext>
>
> with mine.
>
> What is different concerns the TransactionManager used.
>
> In the example, this is the Spring one:
>
>     <!-- setup spring jms TX manager -->
>     <bean id="jmsTransactionManager"
> class="org.springframework.jms.connection.JmsTransactionManager">
>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>     </bean>
>
> and in my case, ActiveMQ is configured to use Geronimo Transaction Manager
> bundle (which in fact uses spring Transaction manager :
> org.springframework.transaction.jta.JtaTransactionManager;)
>
> I suppose that in the example, the policy is defined by default by spring
> when instantiating the class :
> org.springframework.jms.connection.JmsTransactionManager
>
> Is it possible to do the same using a JtaTransaction manager ?
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]> wrote:
>
>> Hi
>>
>> Yeah you need to add all the spring transaction stuff.
>>
>>
>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<[hidden email]>
>> wrote:
>> > Camel generates the following error with my route :
>> >
>> > Route
>> >
>> >        <camel:route>
>> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >            <camel:convertBodyTo type="quickfix.Message" />
>> >            <camel:transacted/>
>> >            <camel:bean ref="serviceHelper" method="createNotification"
>> />
>> >            <camel:bean ref="serviceHelper" method="generateError" />
>> >            <camel:to ref="directNotificationEndpoint" />
>> >        </camel:route>
>> >
>> > It seems that policy must be defined but in the example here it is not
>> > mentioned : http://camel.apache.org/transactional-client.html
>> >
>> > Error :
>> >
>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
>>    |
>> > BundleApplicationContextListener   50 | Application context refresh
>> failed
>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>> > config=osgibundle:/META-INF/spring/*.xml))
>> > org.apache.camel.RuntimeCamelException:
>> java.lang.IllegalArgumentException:
>> > policy must be specified on: Transacted[ref: null]
>> >    at
>> >
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>> >    at
>> >
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>> >    at
>> >
>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>> >    at
>> >
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>> >    at
>> >
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>> >    at
>> >
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>> >    at
>> >
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>> >    at
>> >
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>> >    at
>> >
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>> >    at
>> >
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>> >    at
>> >
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>> >    at
>> >
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>> >    at
>> >
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>> >    at java.lang.Thread.run(Thread.java:619)
>> > Caused by: java.lang.IllegalArgumentException: policy must be specified
>> on:
>> > Transacted[ref: null]
>> >    at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>> >    at
>> >
>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>> >    at
>> >
>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>> >    at
>> >
>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>> >    at
>> >
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>> >    at
>> >
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>> >    at
>> >
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>> >    at
>> >
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>> >    at
>> >
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>> >    at
>> >
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>> >    at
>> >
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>> >    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>> >    at
>> >
>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>> >    at
>> >
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>> >    at
>> >
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Claus Ibsen-2
Transacted also have a ref attribute

<transacted ref="required"/>

Is queueQuickFixInEndpoint a JMS queue?
You need to use a TX manager that can do both JMS and DB.



On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<[hidden email]> wrote:

> I have been able to solve my problem by adding the following bean definition
> :
>
>    <bean id="required"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>        <property name="transactionManager">
>            <osgi:reference
> interface="org.springframework.transaction.PlatformTransactionManager"/>
>        </property>
>    </bean>
>
> and in the route
>
>        <camel:route>
>            <camel:from ref="queueQuickFixInEndpoint" />
>            <camel:convertBodyTo type="quickfix.Message" />
>            <camel:transacted/>
>            <camel:policy ref="required" />
>            <camel:bean ref="serviceHelper" method="createNotification" />
>            <camel:bean ref="serviceHelper" method="generateError" />
>            <camel:to ref="directNotificationEndpoint" />
>        </camel:route>
>
> Unfortunately, the rollback does not occur in the DB and 6 records have been
> created by the method createNotification when error has been raised by the
> method generateError.
>
> What is missing ?
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <[hidden email]>wrote:
>
>> When I compare the example : JMSTransactionalClientRollbackTest.xml
>>
>>     <!-- START SNIPPET: e1 -->
>>     <!-- setup JMS connection factory -->
>>     <bean id="jmsConnectionFactory"
>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>         <property name="brokerURL"
>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>>     </bean>
>>
>>     <!-- setup spring jms TX manager -->
>>     <bean id="jmsTransactionManager"
>> class="org.springframework.jms.connection.JmsTransactionManager">
>>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>>     </bean>
>>
>>     <!-- define our activemq component -->
>>     <bean id="activemq"
>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>>         <!-- define the jms consumer/producer as transacted -->
>>         <property name="transacted" value="true"/>
>>         <!-- setup the transaction manager to use -->
>>         <!-- if not provided then Camel will automatic use a
>> JmsTransactionManager, however if you
>>              for instance use a JTA transaction manager then you must
>> configure it -->
>>         <property name="transactionManager" ref="jmsTransactionManager"/>
>>     </bean>
>>     <!-- END SNIPPET: e1 -->
>>
>>     <!-- START SNIPPET: e2 -->
>>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>>         <route>
>>             <!-- 1: from the jms queue -->
>>             <from uri="activemq:queue:okay"/>
>>             <!-- 2: mark this route as transacted -->
>>             <transacted/>
>>             <!-- 3: call our business logic that is myProcessor -->
>>             <process ref="myProcessor"/>
>>             <!-- 4: if success then send it to the mock -->
>>             <to uri="mock:result"/>
>>         </route>
>>     </camelContext>
>>
>> with mine.
>>
>> What is different concerns the TransactionManager used.
>>
>> In the example, this is the Spring one:
>>
>>     <!-- setup spring jms TX manager -->
>>     <bean id="jmsTransactionManager"
>> class="org.springframework.jms.connection.JmsTransactionManager">
>>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>>     </bean>
>>
>> and in my case, ActiveMQ is configured to use Geronimo Transaction Manager
>> bundle (which in fact uses spring Transaction manager :
>> org.springframework.transaction.jta.JtaTransactionManager;)
>>
>> I suppose that in the example, the policy is defined by default by spring
>> when instantiating the class :
>> org.springframework.jms.connection.JmsTransactionManager
>>
>> Is it possible to do the same using a JtaTransaction manager ?
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]> wrote:
>>
>>> Hi
>>>
>>> Yeah you need to add all the spring transaction stuff.
>>>
>>>
>>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<[hidden email]>
>>> wrote:
>>> > Camel generates the following error with my route :
>>> >
>>> > Route
>>> >
>>> >        <camel:route>
>>> >            <camel:from ref="queueQuickFixInEndpoint" />
>>> >            <camel:convertBodyTo type="quickfix.Message" />
>>> >            <camel:transacted/>
>>> >            <camel:bean ref="serviceHelper" method="createNotification"
>>> />
>>> >            <camel:bean ref="serviceHelper" method="generateError" />
>>> >            <camel:to ref="directNotificationEndpoint" />
>>> >        </camel:route>
>>> >
>>> > It seems that policy must be defined but in the example here it is not
>>> > mentioned : http://camel.apache.org/transactional-client.html
>>> >
>>> > Error :
>>> >
>>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
>>>    |
>>> > BundleApplicationContextListener   50 | Application context refresh
>>> failed
>>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>>> > config=osgibundle:/META-INF/spring/*.xml))
>>> > org.apache.camel.RuntimeCamelException:
>>> java.lang.IllegalArgumentException:
>>> > policy must be specified on: Transacted[ref: null]
>>> >    at
>>> >
>>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>>> >    at
>>> >
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>>> >    at
>>> >
>>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>>> >    at
>>> >
>>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>> >    at
>>> >
>>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>> >    at
>>> >
>>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>> >    at
>>> >
>>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>>> >    at
>>> >
>>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>>> >    at
>>> >
>>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>>> >    at
>>> >
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>>> >    at
>>> >
>>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>> >    at
>>> >
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>>> >    at
>>> >
>>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>>> >    at java.lang.Thread.run(Thread.java:619)
>>> > Caused by: java.lang.IllegalArgumentException: policy must be specified
>>> on:
>>> > Transacted[ref: null]
>>> >    at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>>> >    at
>>> >
>>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>>> >    at
>>> >
>>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>>> >    at
>>> >
>>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>>> >    at
>>> >
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>>> >    at
>>> >
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>>> >    at
>>> >
>>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>>> >    at
>>> >
>>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>>> >    at
>>> >
>>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>>> >    at
>>> >
>>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>>> >    at
>>> >
>>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>>> >    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>>> >    at
>>> >
>>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>>> >    at
>>> >
>>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>>> >    at
>>> >
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>>> > Charles Moulliard
>>> > Senior Enterprise Architect
>>> > Apache Camel Committer
>>> >
>>> > *****************************
>>> > blog : http://cmoulliard.blogspot.com
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
queueQuickFixInEndpoint is a JMS queue.

I will add the ref to the transacted and retest

Question : I suppose that rollback will not occur if by example JMS and DB
(=Hibernate) does not use the same TransactionManager and don't use this
spring class together :
org.springframework.transaction.PlatformTransactionManager

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]> wrote:

> Transacted also have a ref attribute
>
> <transacted ref="required"/>
>
> Is queueQuickFixInEndpoint a JMS queue?
> You need to use a TX manager that can do both JMS and DB.
>
>
>
> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<[hidden email]>
> wrote:
> > I have been able to solve my problem by adding the following bean
> definition
> > :
> >
> >    <bean id="required"
> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >        <property name="transactionManager">
> >            <osgi:reference
> > interface="org.springframework.transaction.PlatformTransactionManager"/>
> >        </property>
> >    </bean>
> >
> > and in the route
> >
> >        <camel:route>
> >            <camel:from ref="queueQuickFixInEndpoint" />
> >            <camel:convertBodyTo type="quickfix.Message" />
> >            <camel:transacted/>
> >            <camel:policy ref="required" />
> >            <camel:bean ref="serviceHelper" method="createNotification" />
> >            <camel:bean ref="serviceHelper" method="generateError" />
> >            <camel:to ref="directNotificationEndpoint" />
> >        </camel:route>
> >
> > Unfortunately, the rollback does not occur in the DB and 6 records have
> been
> > created by the method createNotification when error has been raised by
> the
> > method generateError.
> >
> > What is missing ?
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <[hidden email]
> >wrote:
> >
> >> When I compare the example : JMSTransactionalClientRollbackTest.xml
> >>
> >>     <!-- START SNIPPET: e1 -->
> >>     <!-- setup JMS connection factory -->
> >>     <bean id="jmsConnectionFactory"
> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >>         <property name="brokerURL"
> >> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
> >>     </bean>
> >>
> >>     <!-- setup spring jms TX manager -->
> >>     <bean id="jmsTransactionManager"
> >> class="org.springframework.jms.connection.JmsTransactionManager">
> >>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
> >>     </bean>
> >>
> >>     <!-- define our activemq component -->
> >>     <bean id="activemq"
> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
> >>         <!-- define the jms consumer/producer as transacted -->
> >>         <property name="transacted" value="true"/>
> >>         <!-- setup the transaction manager to use -->
> >>         <!-- if not provided then Camel will automatic use a
> >> JmsTransactionManager, however if you
> >>              for instance use a JTA transaction manager then you must
> >> configure it -->
> >>         <property name="transactionManager"
> ref="jmsTransactionManager"/>
> >>     </bean>
> >>     <!-- END SNIPPET: e1 -->
> >>
> >>     <!-- START SNIPPET: e2 -->
> >>     <camelContext xmlns="http://camel.apache.org/schema/spring">
> >>         <route>
> >>             <!-- 1: from the jms queue -->
> >>             <from uri="activemq:queue:okay"/>
> >>             <!-- 2: mark this route as transacted -->
> >>             <transacted/>
> >>             <!-- 3: call our business logic that is myProcessor -->
> >>             <process ref="myProcessor"/>
> >>             <!-- 4: if success then send it to the mock -->
> >>             <to uri="mock:result"/>
> >>         </route>
> >>     </camelContext>
> >>
> >> with mine.
> >>
> >> What is different concerns the TransactionManager used.
> >>
> >> In the example, this is the Spring one:
> >>
> >>     <!-- setup spring jms TX manager -->
> >>     <bean id="jmsTransactionManager"
> >> class="org.springframework.jms.connection.JmsTransactionManager">
> >>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
> >>     </bean>
> >>
> >> and in my case, ActiveMQ is configured to use Geronimo Transaction
> Manager
> >> bundle (which in fact uses spring Transaction manager :
> >> org.springframework.transaction.jta.JtaTransactionManager;)
> >>
> >> I suppose that in the example, the policy is defined by default by
> spring
> >> when instantiating the class :
> >> org.springframework.jms.connection.JmsTransactionManager
> >>
> >> Is it possible to do the same using a JtaTransaction manager ?
> >>
> >> Regards,
> >>
> >> Charles Moulliard
> >> Senior Enterprise Architect
> >> Apache Camel Committer
> >>
> >> *****************************
> >> blog : http://cmoulliard.blogspot.com
> >>
> >>
> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]>
> wrote:
> >>
> >>> Hi
> >>>
> >>> Yeah you need to add all the spring transaction stuff.
> >>>
> >>>
> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<[hidden email]
> >
> >>> wrote:
> >>> > Camel generates the following error with my route :
> >>> >
> >>> > Route
> >>> >
> >>> >        <camel:route>
> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
> >>> >            <camel:convertBodyTo type="quickfix.Message" />
> >>> >            <camel:transacted/>
> >>> >            <camel:bean ref="serviceHelper"
> method="createNotification"
> >>> />
> >>> >            <camel:bean ref="serviceHelper" method="generateError" />
> >>> >            <camel:to ref="directNotificationEndpoint" />
> >>> >        </camel:route>
> >>> >
> >>> > It seems that policy must be defined but in the example here it is
> not
> >>> > mentioned : http://camel.apache.org/transactional-client.html
> >>> >
> >>> > Error :
> >>> >
> >>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
> >>>    |
> >>> > BundleApplicationContextListener   50 | Application context refresh
> >>> failed
> >>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> >>> > config=osgibundle:/META-INF/spring/*.xml))
> >>> > org.apache.camel.RuntimeCamelException:
> >>> java.lang.IllegalArgumentException:
> >>> > policy must be specified on: Transacted[ref: null]
> >>> >    at
> >>> >
> >>>
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
> >>> >    at
> >>> >
> >>>
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
> >>> >    at
> >>> >
> >>>
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> >>> >    at
> >>> >
> >>>
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
> >>> >    at
> >>> >
> >>>
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
> >>> >    at
> >>> >
> >>>
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
> >>> >    at
> >>> >
> >>>
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
> >>> >    at
> >>> >
> >>>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
> >>> >    at
> >>> >
> >>>
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> >>> >    at
> >>> >
> >>>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> >>> >    at
> >>> >
> >>>
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
> >>> >    at java.lang.Thread.run(Thread.java:619)
> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
> specified
> >>> on:
> >>> > Transacted[ref: null]
> >>> >    at
> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
> >>> >    at
> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
> >>> >    at
> >>> >
> >>>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> >>> > Charles Moulliard
> >>> > Senior Enterprise Architect
> >>> > Apache Camel Committer
> >>> >
> >>> > *****************************
> >>> > blog : http://cmoulliard.blogspot.com
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Claus Ibsen
> >>> Apache Camel Committer
> >>>
> >>> Open Source Integration: http://fusesource.com
> >>> Blog: http://davsclaus.blogspot.com/
> >>> Twitter: http://twitter.com/davsclaus
> >>>
> >>
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Claus Ibsen-2
On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<[hidden email]> wrote:
> queueQuickFixInEndpoint is a JMS queue.
>
> I will add the ref to the transacted and retest
>
> Question : I suppose that rollback will not occur if by example JMS and DB
> (=Hibernate) does not use the same TransactionManager and don't use this
> spring class together :
> org.springframework.transaction.PlatformTransactionManager
Yes they must be configured to use the same TX manager.


>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]> wrote:
>
>> Transacted also have a ref attribute
>>
>> <transacted ref="required"/>
>>
>> Is queueQuickFixInEndpoint a JMS queue?
>> You need to use a TX manager that can do both JMS and DB.
>>
>>
>>
>> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<[hidden email]>
>> wrote:
>> > I have been able to solve my problem by adding the following bean
>> definition
>> > :
>> >
>> >    <bean id="required"
>> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >        <property name="transactionManager">
>> >            <osgi:reference
>> > interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >        </property>
>> >    </bean>
>> >
>> > and in the route
>> >
>> >        <camel:route>
>> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >            <camel:convertBodyTo type="quickfix.Message" />
>> >            <camel:transacted/>
>> >            <camel:policy ref="required" />
>> >            <camel:bean ref="serviceHelper" method="createNotification" />
>> >            <camel:bean ref="serviceHelper" method="generateError" />
>> >            <camel:to ref="directNotificationEndpoint" />
>> >        </camel:route>
>> >
>> > Unfortunately, the rollback does not occur in the DB and 6 records have
>> been
>> > created by the method createNotification when error has been raised by
>> the
>> > method generateError.
>> >
>> > What is missing ?
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>> >
>> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <[hidden email]
>> >wrote:
>> >
>> >> When I compare the example : JMSTransactionalClientRollbackTest.xml
>> >>
>> >>     <!-- START SNIPPET: e1 -->
>> >>     <!-- setup JMS connection factory -->
>> >>     <bean id="jmsConnectionFactory"
>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >>         <property name="brokerURL"
>> >> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>> >>     </bean>
>> >>
>> >>     <!-- setup spring jms TX manager -->
>> >>     <bean id="jmsTransactionManager"
>> >> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>> >>     </bean>
>> >>
>> >>     <!-- define our activemq component -->
>> >>     <bean id="activemq"
>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>> >>         <!-- define the jms consumer/producer as transacted -->
>> >>         <property name="transacted" value="true"/>
>> >>         <!-- setup the transaction manager to use -->
>> >>         <!-- if not provided then Camel will automatic use a
>> >> JmsTransactionManager, however if you
>> >>              for instance use a JTA transaction manager then you must
>> >> configure it -->
>> >>         <property name="transactionManager"
>> ref="jmsTransactionManager"/>
>> >>     </bean>
>> >>     <!-- END SNIPPET: e1 -->
>> >>
>> >>     <!-- START SNIPPET: e2 -->
>> >>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>> >>         <route>
>> >>             <!-- 1: from the jms queue -->
>> >>             <from uri="activemq:queue:okay"/>
>> >>             <!-- 2: mark this route as transacted -->
>> >>             <transacted/>
>> >>             <!-- 3: call our business logic that is myProcessor -->
>> >>             <process ref="myProcessor"/>
>> >>             <!-- 4: if success then send it to the mock -->
>> >>             <to uri="mock:result"/>
>> >>         </route>
>> >>     </camelContext>
>> >>
>> >> with mine.
>> >>
>> >> What is different concerns the TransactionManager used.
>> >>
>> >> In the example, this is the Spring one:
>> >>
>> >>     <!-- setup spring jms TX manager -->
>> >>     <bean id="jmsTransactionManager"
>> >> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>> >>     </bean>
>> >>
>> >> and in my case, ActiveMQ is configured to use Geronimo Transaction
>> Manager
>> >> bundle (which in fact uses spring Transaction manager :
>> >> org.springframework.transaction.jta.JtaTransactionManager;)
>> >>
>> >> I suppose that in the example, the policy is defined by default by
>> spring
>> >> when instantiating the class :
>> >> org.springframework.jms.connection.JmsTransactionManager
>> >>
>> >> Is it possible to do the same using a JtaTransaction manager ?
>> >>
>> >> Regards,
>> >>
>> >> Charles Moulliard
>> >> Senior Enterprise Architect
>> >> Apache Camel Committer
>> >>
>> >> *****************************
>> >> blog : http://cmoulliard.blogspot.com
>> >>
>> >>
>> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]>
>> wrote:
>> >>
>> >>> Hi
>> >>>
>> >>> Yeah you need to add all the spring transaction stuff.
>> >>>
>> >>>
>> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<[hidden email]
>> >
>> >>> wrote:
>> >>> > Camel generates the following error with my route :
>> >>> >
>> >>> > Route
>> >>> >
>> >>> >        <camel:route>
>> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >>> >            <camel:convertBodyTo type="quickfix.Message" />
>> >>> >            <camel:transacted/>
>> >>> >            <camel:bean ref="serviceHelper"
>> method="createNotification"
>> >>> />
>> >>> >            <camel:bean ref="serviceHelper" method="generateError" />
>> >>> >            <camel:to ref="directNotificationEndpoint" />
>> >>> >        </camel:route>
>> >>> >
>> >>> > It seems that policy must be defined but in the example here it is
>> not
>> >>> > mentioned : http://camel.apache.org/transactional-client.html
>> >>> >
>> >>> > Error :
>> >>> >
>> >>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
>> >>>    |
>> >>> > BundleApplicationContextListener   50 | Application context refresh
>> >>> failed
>> >>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>> >>> > config=osgibundle:/META-INF/spring/*.xml))
>> >>> > org.apache.camel.RuntimeCamelException:
>> >>> java.lang.IllegalArgumentException:
>> >>> > policy must be specified on: Transacted[ref: null]
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>> >>> >    at
>> >>> >
>> >>>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>> >>> >    at java.lang.Thread.run(Thread.java:619)
>> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
>> specified
>> >>> on:
>> >>> > Transacted[ref: null]
>> >>> >    at
>> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>> >>> >    at
>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>> >>> >    at
>> >>> >
>> >>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>> >>> > Charles Moulliard
>> >>> > Senior Enterprise Architect
>> >>> > Apache Camel Committer
>> >>> >
>> >>> > *****************************
>> >>> > blog : http://cmoulliard.blogspot.com
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Claus Ibsen
>> >>> Apache Camel Committer
>> >>>
>> >>> Open Source Integration: http://fusesource.com
>> >>> Blog: http://davsclaus.blogspot.com/
>> >>> Twitter: http://twitter.com/davsclaus
>> >>>
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
OK. I will try to create my own Hibernate JTATransaction manager as the
existing try to perform a JNDI lookup to find the transaction manager on
OSGI platform (inheritage from J2EE world)

http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E


Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]> wrote:

> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<[hidden email]>
> wrote:
> > queueQuickFixInEndpoint is a JMS queue.
> >
> > I will add the ref to the transacted and retest
> >
> > Question : I suppose that rollback will not occur if by example JMS and
> DB
> > (=Hibernate) does not use the same TransactionManager and don't use this
> > spring class together :
> > org.springframework.transaction.PlatformTransactionManager
> Yes they must be configured to use the same TX manager.
>
>
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]>
> wrote:
> >
> >> Transacted also have a ref attribute
> >>
> >> <transacted ref="required"/>
> >>
> >> Is queueQuickFixInEndpoint a JMS queue?
> >> You need to use a TX manager that can do both JMS and DB.
> >>
> >>
> >>
> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<[hidden email]>
> >> wrote:
> >> > I have been able to solve my problem by adding the following bean
> >> definition
> >> > :
> >> >
> >> >    <bean id="required"
> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >> >        <property name="transactionManager">
> >> >            <osgi:reference
> >> >
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >> >        </property>
> >> >    </bean>
> >> >
> >> > and in the route
> >> >
> >> >        <camel:route>
> >> >            <camel:from ref="queueQuickFixInEndpoint" />
> >> >            <camel:convertBodyTo type="quickfix.Message" />
> >> >            <camel:transacted/>
> >> >            <camel:policy ref="required" />
> >> >            <camel:bean ref="serviceHelper" method="createNotification"
> />
> >> >            <camel:bean ref="serviceHelper" method="generateError" />
> >> >            <camel:to ref="directNotificationEndpoint" />
> >> >        </camel:route>
> >> >
> >> > Unfortunately, the rollback does not occur in the DB and 6 records
> have
> >> been
> >> > created by the method createNotification when error has been raised by
> >> the
> >> > method generateError.
> >> >
> >> > What is missing ?
> >> >
> >> > Charles Moulliard
> >> > Senior Enterprise Architect
> >> > Apache Camel Committer
> >> >
> >> > *****************************
> >> > blog : http://cmoulliard.blogspot.com
> >> >
> >> >
> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
> [hidden email]
> >> >wrote:
> >> >
> >> >> When I compare the example : JMSTransactionalClientRollbackTest.xml
> >> >>
> >> >>     <!-- START SNIPPET: e1 -->
> >> >>     <!-- setup JMS connection factory -->
> >> >>     <bean id="jmsConnectionFactory"
> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >> >>         <property name="brokerURL"
> >> >>
> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
> >> >>     </bean>
> >> >>
> >> >>     <!-- setup spring jms TX manager -->
> >> >>     <bean id="jmsTransactionManager"
> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
> >> >>         <property name="connectionFactory"
> ref="jmsConnectionFactory"/>
> >> >>     </bean>
> >> >>
> >> >>     <!-- define our activemq component -->
> >> >>     <bean id="activemq"
> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >> >>         <property name="connectionFactory"
> ref="jmsConnectionFactory"/>
> >> >>         <!-- define the jms consumer/producer as transacted -->
> >> >>         <property name="transacted" value="true"/>
> >> >>         <!-- setup the transaction manager to use -->
> >> >>         <!-- if not provided then Camel will automatic use a
> >> >> JmsTransactionManager, however if you
> >> >>              for instance use a JTA transaction manager then you must
> >> >> configure it -->
> >> >>         <property name="transactionManager"
> >> ref="jmsTransactionManager"/>
> >> >>     </bean>
> >> >>     <!-- END SNIPPET: e1 -->
> >> >>
> >> >>     <!-- START SNIPPET: e2 -->
> >> >>     <camelContext xmlns="http://camel.apache.org/schema/spring">
> >> >>         <route>
> >> >>             <!-- 1: from the jms queue -->
> >> >>             <from uri="activemq:queue:okay"/>
> >> >>             <!-- 2: mark this route as transacted -->
> >> >>             <transacted/>
> >> >>             <!-- 3: call our business logic that is myProcessor -->
> >> >>             <process ref="myProcessor"/>
> >> >>             <!-- 4: if success then send it to the mock -->
> >> >>             <to uri="mock:result"/>
> >> >>         </route>
> >> >>     </camelContext>
> >> >>
> >> >> with mine.
> >> >>
> >> >> What is different concerns the TransactionManager used.
> >> >>
> >> >> In the example, this is the Spring one:
> >> >>
> >> >>     <!-- setup spring jms TX manager -->
> >> >>     <bean id="jmsTransactionManager"
> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
> >> >>         <property name="connectionFactory"
> ref="jmsConnectionFactory"/>
> >> >>     </bean>
> >> >>
> >> >> and in my case, ActiveMQ is configured to use Geronimo Transaction
> >> Manager
> >> >> bundle (which in fact uses spring Transaction manager :
> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
> >> >>
> >> >> I suppose that in the example, the policy is defined by default by
> >> spring
> >> >> when instantiating the class :
> >> >> org.springframework.jms.connection.JmsTransactionManager
> >> >>
> >> >> Is it possible to do the same using a JtaTransaction manager ?
> >> >>
> >> >> Regards,
> >> >>
> >> >> Charles Moulliard
> >> >> Senior Enterprise Architect
> >> >> Apache Camel Committer
> >> >>
> >> >> *****************************
> >> >> blog : http://cmoulliard.blogspot.com
> >> >>
> >> >>
> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]>
> >> wrote:
> >> >>
> >> >>> Hi
> >> >>>
> >> >>> Yeah you need to add all the spring transaction stuff.
> >> >>>
> >> >>>
> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
> [hidden email]
> >> >
> >> >>> wrote:
> >> >>> > Camel generates the following error with my route :
> >> >>> >
> >> >>> > Route
> >> >>> >
> >> >>> >        <camel:route>
> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
> >> >>> >            <camel:convertBodyTo type="quickfix.Message" />
> >> >>> >            <camel:transacted/>
> >> >>> >            <camel:bean ref="serviceHelper"
> >> method="createNotification"
> >> >>> />
> >> >>> >            <camel:bean ref="serviceHelper" method="generateError"
> />
> >> >>> >            <camel:to ref="directNotificationEndpoint" />
> >> >>> >        </camel:route>
> >> >>> >
> >> >>> > It seems that policy must be defined but in the example here it is
> >> not
> >> >>> > mentioned : http://camel.apache.org/transactional-client.html
> >> >>> >
> >> >>> > Error :
> >> >>> >
> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
> >> >>>    |
> >> >>> > BundleApplicationContextListener   50 | Application context
> refresh
> >> >>> failed
> >> >>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
> >> >>> > org.apache.camel.RuntimeCamelException:
> >> >>> java.lang.IllegalArgumentException:
> >> >>> > policy must be specified on: Transacted[ref: null]
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
> >> >>> >    at java.lang.Thread.run(Thread.java:619)
> >> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
> >> specified
> >> >>> on:
> >> >>> > Transacted[ref: null]
> >> >>> >    at
> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
> >> >>> >    at
> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
> >> >>> >    at
> >> >>> >
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> >> >>> > Charles Moulliard
> >> >>> > Senior Enterprise Architect
> >> >>> > Apache Camel Committer
> >> >>> >
> >> >>> > *****************************
> >> >>> > blog : http://cmoulliard.blogspot.com
> >> >>> >
> >> >>>
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Claus Ibsen
> >> >>> Apache Camel Committer
> >> >>>
> >> >>> Open Source Integration: http://fusesource.com
> >> >>> Blog: http://davsclaus.blogspot.com/
> >> >>> Twitter: http://twitter.com/davsclaus
> >> >>>
> >> >>
> >> >>
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
I'm still fighting against Spring config or Camel because Rollback does not
occur. I have been able to configure Hibernate to use the same
TransactionManager as the one used by JMS

Here is the different part of the config. I don't know where the issue could
be !

1) ActiveMQ

...

    <bean id="activemqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616" />
    </bean>

    <bean id="pooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactoryBean">
        <property name="maxConnections" value="8" />
        <property name="maximumActive" value="500" />
        <property name="transactionManager" ref="transactionManager" />
        <property name="connectionFactory" ref="activemqConnectionFactory"
/>
        <property name="resourceName" value="activemq.default" />
    </bean>

    <bean id="resourceManager"
class="org.apache.activemq.pool.ActiveMQResourceManager"
init-method="recoverResource">
          <property name="transactionManager" ref="transactionManager" />
          <property name="connectionFactory" ref="activemqConnectionFactory"
/>
          <property name="resourceName" value="activemq.default" />
    </bean>

    <osgi:reference id="transactionManager"
interface="javax.transaction.TransactionManager" /> // This OSGI service is
published by Geronimo Transaction bundle

    <osgi:service ref="pooledConnectionFactory">
        <osgi:interfaces>
            <value>javax.jms.ConnectionFactory</value>
        </osgi:interfaces>
        <osgi:service-properties>
            <entry key="name" value="default"/>
        </osgi:service-properties>
    </osgi:service>

2) Camel ActiveMQComponent

    <bean id="active-mq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="transacted" value="true"/>
        <property name="connectionFactory">
            <osgi:reference interface="javax.jms.ConnectionFactory"/> //
OSGI service is published by ActiveMQ service
        </property>
        <property name="transactionManager">
            <osgi:reference
interface="org.springframework.transaction.PlatformTransactionManager"/>
        </property>
    </bean>

2) Hibernate - DAO

    <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

        <property name="mappingLocations">
            <list>

<value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
            </list>
        </property>

        <property name="hibernateProperties">
            <props>
                <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop
key="hibernate.cglib.use_reflection_optimizer">true</prop>
                <prop key="hibernate.jdbc.batch_size">10</prop>
                <prop
key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
                <prop
key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
            </props>
        </property>
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>

Remark : To avoid the JNDI lookup issue, we use springTransactionFactory as
the TransactionFactory for Hibernate (
http://forum.springsource.org/showthread.php?p=215720)

3) Service layer

Here is the definition of the service used from Camel route :

    <bean id="notificationServiceTarget"
class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
            <property name="notificationDAO">
            <osgi:reference
interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
        </property>

    </bean>

   <!-- Abstract service using the Geronimo Transaction Manager -->
    <bean id="abstractService" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
         <property name="transactionManager">
            <osgi:reference
interface="org.springframework.transaction.PlatformTransactionManager"/>
        </property>
    </bean>

    <bean id="notificationService"
          parent="abstractService"

class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

        <property name="target">
            <ref bean="notificationServiceTarget" />
        </property>

        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>

4) Route

    <bean id="myPolicy" class="org.apache.camel.processor.RedeliveryPolicy">
        <property name="maximumRedeliveries" value="1"/>
    </bean>

    <bean id="txErrorHandler"
class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
        <property name="springTransactionPolicy"
ref="PROPAGATION_REQUIRED"/>
        <property name="redeliveryPolicy" ref="myPolicy"/>
    </bean>

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

        <camel:route errorHandlerRef="txErrorHandler">
            <camel:from ref="queueQuickFixInEndpoint" />
            <camel:convertBodyTo type="quickfix.Message" />
            <camel:transacted ref="PROPAGATION_REQUIRED"/>
            <camel:bean ref="serviceHelper" method="createNotification" />
            <camel:bean ref="serviceHelper" method="generateError" />
            <camel:to ref="directNotificationEndpoint" />
        </camel:route>

Any ideas are welcome

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <[hidden email]>wrote:

> OK. I will try to create my own Hibernate JTATransaction manager as the
> existing try to perform a JNDI lookup to find the transaction manager on
> OSGI platform (inheritage from J2EE world)
>
>
> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]> wrote:
>
>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<[hidden email]>
>> wrote:
>> > queueQuickFixInEndpoint is a JMS queue.
>> >
>> > I will add the ref to the transacted and retest
>> >
>> > Question : I suppose that rollback will not occur if by example JMS and
>> DB
>> > (=Hibernate) does not use the same TransactionManager and don't use this
>> > spring class together :
>> > org.springframework.transaction.PlatformTransactionManager
>> Yes they must be configured to use the same TX manager.
>>
>>
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>> >
>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]>
>> wrote:
>> >
>> >> Transacted also have a ref attribute
>> >>
>> >> <transacted ref="required"/>
>> >>
>> >> Is queueQuickFixInEndpoint a JMS queue?
>> >> You need to use a TX manager that can do both JMS and DB.
>> >>
>> >>
>> >>
>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<[hidden email]
>> >
>> >> wrote:
>> >> > I have been able to solve my problem by adding the following bean
>> >> definition
>> >> > :
>> >> >
>> >> >    <bean id="required"
>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >> >        <property name="transactionManager">
>> >> >            <osgi:reference
>> >> >
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >> >        </property>
>> >> >    </bean>
>> >> >
>> >> > and in the route
>> >> >
>> >> >        <camel:route>
>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>> >> >            <camel:transacted/>
>> >> >            <camel:policy ref="required" />
>> >> >            <camel:bean ref="serviceHelper"
>> method="createNotification" />
>> >> >            <camel:bean ref="serviceHelper" method="generateError" />
>> >> >            <camel:to ref="directNotificationEndpoint" />
>> >> >        </camel:route>
>> >> >
>> >> > Unfortunately, the rollback does not occur in the DB and 6 records
>> have
>> >> been
>> >> > created by the method createNotification when error has been raised
>> by
>> >> the
>> >> > method generateError.
>> >> >
>> >> > What is missing ?
>> >> >
>> >> > Charles Moulliard
>> >> > Senior Enterprise Architect
>> >> > Apache Camel Committer
>> >> >
>> >> > *****************************
>> >> > blog : http://cmoulliard.blogspot.com
>> >> >
>> >> >
>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>> [hidden email]
>> >> >wrote:
>> >> >
>> >> >> When I compare the example : JMSTransactionalClientRollbackTest.xml
>> >> >>
>> >> >>     <!-- START SNIPPET: e1 -->
>> >> >>     <!-- setup JMS connection factory -->
>> >> >>     <bean id="jmsConnectionFactory"
>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >> >>         <property name="brokerURL"
>> >> >>
>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>> >> >>     </bean>
>> >> >>
>> >> >>     <!-- setup spring jms TX manager -->
>> >> >>     <bean id="jmsTransactionManager"
>> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
>> >> >>         <property name="connectionFactory"
>> ref="jmsConnectionFactory"/>
>> >> >>     </bean>
>> >> >>
>> >> >>     <!-- define our activemq component -->
>> >> >>     <bean id="activemq"
>> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >> >>         <property name="connectionFactory"
>> ref="jmsConnectionFactory"/>
>> >> >>         <!-- define the jms consumer/producer as transacted -->
>> >> >>         <property name="transacted" value="true"/>
>> >> >>         <!-- setup the transaction manager to use -->
>> >> >>         <!-- if not provided then Camel will automatic use a
>> >> >> JmsTransactionManager, however if you
>> >> >>              for instance use a JTA transaction manager then you
>> must
>> >> >> configure it -->
>> >> >>         <property name="transactionManager"
>> >> ref="jmsTransactionManager"/>
>> >> >>     </bean>
>> >> >>     <!-- END SNIPPET: e1 -->
>> >> >>
>> >> >>     <!-- START SNIPPET: e2 -->
>> >> >>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>> >> >>         <route>
>> >> >>             <!-- 1: from the jms queue -->
>> >> >>             <from uri="activemq:queue:okay"/>
>> >> >>             <!-- 2: mark this route as transacted -->
>> >> >>             <transacted/>
>> >> >>             <!-- 3: call our business logic that is myProcessor -->
>> >> >>             <process ref="myProcessor"/>
>> >> >>             <!-- 4: if success then send it to the mock -->
>> >> >>             <to uri="mock:result"/>
>> >> >>         </route>
>> >> >>     </camelContext>
>> >> >>
>> >> >> with mine.
>> >> >>
>> >> >> What is different concerns the TransactionManager used.
>> >> >>
>> >> >> In the example, this is the Spring one:
>> >> >>
>> >> >>     <!-- setup spring jms TX manager -->
>> >> >>     <bean id="jmsTransactionManager"
>> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
>> >> >>         <property name="connectionFactory"
>> ref="jmsConnectionFactory"/>
>> >> >>     </bean>
>> >> >>
>> >> >> and in my case, ActiveMQ is configured to use Geronimo Transaction
>> >> Manager
>> >> >> bundle (which in fact uses spring Transaction manager :
>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>> >> >>
>> >> >> I suppose that in the example, the policy is defined by default by
>> >> spring
>> >> >> when instantiating the class :
>> >> >> org.springframework.jms.connection.JmsTransactionManager
>> >> >>
>> >> >> Is it possible to do the same using a JtaTransaction manager ?
>> >> >>
>> >> >> Regards,
>> >> >>
>> >> >> Charles Moulliard
>> >> >> Senior Enterprise Architect
>> >> >> Apache Camel Committer
>> >> >>
>> >> >> *****************************
>> >> >> blog : http://cmoulliard.blogspot.com
>> >> >>
>> >> >>
>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]>
>> >> wrote:
>> >> >>
>> >> >>> Hi
>> >> >>>
>> >> >>> Yeah you need to add all the spring transaction stuff.
>> >> >>>
>> >> >>>
>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>> [hidden email]
>> >> >
>> >> >>> wrote:
>> >> >>> > Camel generates the following error with my route :
>> >> >>> >
>> >> >>> > Route
>> >> >>> >
>> >> >>> >        <camel:route>
>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >> >>> >            <camel:convertBodyTo type="quickfix.Message" />
>> >> >>> >            <camel:transacted/>
>> >> >>> >            <camel:bean ref="serviceHelper"
>> >> method="createNotification"
>> >> >>> />
>> >> >>> >            <camel:bean ref="serviceHelper" method="generateError"
>> />
>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>> >> >>> >        </camel:route>
>> >> >>> >
>> >> >>> > It seems that policy must be defined but in the example here it
>> is
>> >> not
>> >> >>> > mentioned : http://camel.apache.org/transactional-client.html
>> >> >>> >
>> >> >>> > Error :
>> >> >>> >
>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
>> >> >>>    |
>> >> >>> > BundleApplicationContextListener   50 | Application context
>> refresh
>> >> >>> failed
>> >> >>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>> >> >>> > org.apache.camel.RuntimeCamelException:
>> >> >>> java.lang.IllegalArgumentException:
>> >> >>> > policy must be specified on: Transacted[ref: null]
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
>> >> specified
>> >> >>> on:
>> >> >>> > Transacted[ref: null]
>> >> >>> >    at
>> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>> >> >>> >    at
>> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>> >> >>> >    at
>> >> >>> >
>> >> >>>
>> >>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>> >> >>> > Charles Moulliard
>> >> >>> > Senior Enterprise Architect
>> >> >>> > Apache Camel Committer
>> >> >>> >
>> >> >>> > *****************************
>> >> >>> > blog : http://cmoulliard.blogspot.com
>> >> >>> >
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> --
>> >> >>> Claus Ibsen
>> >> >>> Apache Camel Committer
>> >> >>>
>> >> >>> Open Source Integration: http://fusesource.com
>> >> >>> Blog: http://davsclaus.blogspot.com/
>> >> >>> Twitter: http://twitter.com/davsclaus
>> >> >>>
>> >> >>
>> >> >>
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> Apache Camel Committer
>> >>
>> >> Open Source Integration: http://fusesource.com
>> >> Blog: http://davsclaus.blogspot.com/
>> >> Twitter: http://twitter.com/davsclaus
>> >>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Claus Ibsen-2
Hi

Get it working outside OSGi, eg in a small unit test thats easy to run
and test from within your IDE.
Google for JMS + hibernate + TX + XA to find some samples that work.

And since you use JMS + DB in the same TX you need to use XA db driver.

It can be a painful to get setup
http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html

And you need an XA TX manager such as JOTM
http://jotm.ow2.org/xwiki/bin/view/Main/WebHome

In j2ee land there was a JTA with the container that could do it. But
in your OSGi container I do not know if it provides one out of the
box.


On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<[hidden email]> wrote:

> I'm still fighting against Spring config or Camel because Rollback does not
> occur. I have been able to configure Hibernate to use the same
> TransactionManager as the one used by JMS
>
> Here is the different part of the config. I don't know where the issue could
> be !
>
> 1) ActiveMQ
>
> ...
>
>    <bean id="activemqConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>        <property name="brokerURL" value="tcp://localhost:61616" />
>    </bean>
>
>    <bean id="pooledConnectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
>        <property name="maxConnections" value="8" />
>        <property name="maximumActive" value="500" />
>        <property name="transactionManager" ref="transactionManager" />
>        <property name="connectionFactory" ref="activemqConnectionFactory"
> />
>        <property name="resourceName" value="activemq.default" />
>    </bean>
>
>    <bean id="resourceManager"
> class="org.apache.activemq.pool.ActiveMQResourceManager"
> init-method="recoverResource">
>          <property name="transactionManager" ref="transactionManager" />
>          <property name="connectionFactory" ref="activemqConnectionFactory"
> />
>          <property name="resourceName" value="activemq.default" />
>    </bean>
>
>    <osgi:reference id="transactionManager"
> interface="javax.transaction.TransactionManager" /> // This OSGI service is
> published by Geronimo Transaction bundle
>
>    <osgi:service ref="pooledConnectionFactory">
>        <osgi:interfaces>
>            <value>javax.jms.ConnectionFactory</value>
>        </osgi:interfaces>
>        <osgi:service-properties>
>            <entry key="name" value="default"/>
>        </osgi:service-properties>
>    </osgi:service>
>
> 2) Camel ActiveMQComponent
>
>    <bean id="active-mq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>        <property name="transacted" value="true"/>
>        <property name="connectionFactory">
>            <osgi:reference interface="javax.jms.ConnectionFactory"/> //
> OSGI service is published by ActiveMQ service
>        </property>
>        <property name="transactionManager">
>            <osgi:reference
> interface="org.springframework.transaction.PlatformTransactionManager"/>
>        </property>
>    </bean>
>
> 2) Hibernate - DAO
>
>    <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>
>        <property name="mappingLocations">
>            <list>
>
> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
>            </list>
>        </property>
>
>        <property name="hibernateProperties">
>            <props>
>                <prop
> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>                <prop key="hibernate.show_sql">true</prop>
>                <prop key="hibernate.format_sql">true</prop>
>                <prop
> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>                <prop key="hibernate.jdbc.batch_size">10</prop>
>                <prop
> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
>                <prop
> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
>            </props>
>        </property>
>        <property name="dataSource">
>            <ref bean="dataSource" />
>        </property>
>
> Remark : To avoid the JNDI lookup issue, we use springTransactionFactory as
> the TransactionFactory for Hibernate (
> http://forum.springsource.org/showthread.php?p=215720)
>
> 3) Service layer
>
> Here is the definition of the service used from Camel route :
>
>    <bean id="notificationServiceTarget"
> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
>            <property name="notificationDAO">
>            <osgi:reference
> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
>        </property>
>
>    </bean>
>
>   <!-- Abstract service using the Geronimo Transaction Manager -->
>    <bean id="abstractService" abstract="true"
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>         <property name="transactionManager">
>            <osgi:reference
> interface="org.springframework.transaction.PlatformTransactionManager"/>
>        </property>
>    </bean>
>
>    <bean id="notificationService"
>          parent="abstractService"
>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>
>        <property name="target">
>            <ref bean="notificationServiceTarget" />
>        </property>
>
>        <property name="transactionAttributes">
>            <props>
>                <prop key="*">PROPAGATION_REQUIRED</prop>
>            </props>
>        </property>
>    </bean>
>
> 4) Route
>
>    <bean id="myPolicy" class="org.apache.camel.processor.RedeliveryPolicy">
>        <property name="maximumRedeliveries" value="1"/>
>    </bean>
>
>    <bean id="txErrorHandler"
> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>        <property name="springTransactionPolicy"
> ref="PROPAGATION_REQUIRED"/>
>        <property name="redeliveryPolicy" ref="myPolicy"/>
>    </bean>
>
>    <bean id="PROPAGATION_REQUIRED"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>        <property name="transactionManager">
>            <osgi:reference
> interface="org.springframework.transaction.PlatformTransactionManager"/>
>        </property>
>    </bean>
>
>        <camel:route errorHandlerRef="txErrorHandler">
>            <camel:from ref="queueQuickFixInEndpoint" />
>            <camel:convertBodyTo type="quickfix.Message" />
>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>            <camel:bean ref="serviceHelper" method="createNotification" />
>            <camel:bean ref="serviceHelper" method="generateError" />
>            <camel:to ref="directNotificationEndpoint" />
>        </camel:route>
>
> Any ideas are welcome
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <[hidden email]>wrote:
>
>> OK. I will try to create my own Hibernate JTATransaction manager as the
>> existing try to perform a JNDI lookup to find the transaction manager on
>> OSGI platform (inheritage from J2EE world)
>>
>>
>> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>>
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]> wrote:
>>
>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<[hidden email]>
>>> wrote:
>>> > queueQuickFixInEndpoint is a JMS queue.
>>> >
>>> > I will add the ref to the transacted and retest
>>> >
>>> > Question : I suppose that rollback will not occur if by example JMS and
>>> DB
>>> > (=Hibernate) does not use the same TransactionManager and don't use this
>>> > spring class together :
>>> > org.springframework.transaction.PlatformTransactionManager
>>> Yes they must be configured to use the same TX manager.
>>>
>>>
>>> >
>>> > Regards,
>>> >
>>> > Charles Moulliard
>>> > Senior Enterprise Architect
>>> > Apache Camel Committer
>>> >
>>> > *****************************
>>> > blog : http://cmoulliard.blogspot.com
>>> >
>>> >
>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]>
>>> wrote:
>>> >
>>> >> Transacted also have a ref attribute
>>> >>
>>> >> <transacted ref="required"/>
>>> >>
>>> >> Is queueQuickFixInEndpoint a JMS queue?
>>> >> You need to use a TX manager that can do both JMS and DB.
>>> >>
>>> >>
>>> >>
>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<[hidden email]
>>> >
>>> >> wrote:
>>> >> > I have been able to solve my problem by adding the following bean
>>> >> definition
>>> >> > :
>>> >> >
>>> >> >    <bean id="required"
>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>> >> >        <property name="transactionManager">
>>> >> >            <osgi:reference
>>> >> >
>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >> >        </property>
>>> >> >    </bean>
>>> >> >
>>> >> > and in the route
>>> >> >
>>> >> >        <camel:route>
>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>>> >> >            <camel:transacted/>
>>> >> >            <camel:policy ref="required" />
>>> >> >            <camel:bean ref="serviceHelper"
>>> method="createNotification" />
>>> >> >            <camel:bean ref="serviceHelper" method="generateError" />
>>> >> >            <camel:to ref="directNotificationEndpoint" />
>>> >> >        </camel:route>
>>> >> >
>>> >> > Unfortunately, the rollback does not occur in the DB and 6 records
>>> have
>>> >> been
>>> >> > created by the method createNotification when error has been raised
>>> by
>>> >> the
>>> >> > method generateError.
>>> >> >
>>> >> > What is missing ?
>>> >> >
>>> >> > Charles Moulliard
>>> >> > Senior Enterprise Architect
>>> >> > Apache Camel Committer
>>> >> >
>>> >> > *****************************
>>> >> > blog : http://cmoulliard.blogspot.com
>>> >> >
>>> >> >
>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>>> [hidden email]
>>> >> >wrote:
>>> >> >
>>> >> >> When I compare the example : JMSTransactionalClientRollbackTest.xml
>>> >> >>
>>> >> >>     <!-- START SNIPPET: e1 -->
>>> >> >>     <!-- setup JMS connection factory -->
>>> >> >>     <bean id="jmsConnectionFactory"
>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>>> >> >>         <property name="brokerURL"
>>> >> >>
>>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>>> >> >>     </bean>
>>> >> >>
>>> >> >>     <!-- setup spring jms TX manager -->
>>> >> >>     <bean id="jmsTransactionManager"
>>> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
>>> >> >>         <property name="connectionFactory"
>>> ref="jmsConnectionFactory"/>
>>> >> >>     </bean>
>>> >> >>
>>> >> >>     <!-- define our activemq component -->
>>> >> >>     <bean id="activemq"
>>> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>> >> >>         <property name="connectionFactory"
>>> ref="jmsConnectionFactory"/>
>>> >> >>         <!-- define the jms consumer/producer as transacted -->
>>> >> >>         <property name="transacted" value="true"/>
>>> >> >>         <!-- setup the transaction manager to use -->
>>> >> >>         <!-- if not provided then Camel will automatic use a
>>> >> >> JmsTransactionManager, however if you
>>> >> >>              for instance use a JTA transaction manager then you
>>> must
>>> >> >> configure it -->
>>> >> >>         <property name="transactionManager"
>>> >> ref="jmsTransactionManager"/>
>>> >> >>     </bean>
>>> >> >>     <!-- END SNIPPET: e1 -->
>>> >> >>
>>> >> >>     <!-- START SNIPPET: e2 -->
>>> >> >>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>>> >> >>         <route>
>>> >> >>             <!-- 1: from the jms queue -->
>>> >> >>             <from uri="activemq:queue:okay"/>
>>> >> >>             <!-- 2: mark this route as transacted -->
>>> >> >>             <transacted/>
>>> >> >>             <!-- 3: call our business logic that is myProcessor -->
>>> >> >>             <process ref="myProcessor"/>
>>> >> >>             <!-- 4: if success then send it to the mock -->
>>> >> >>             <to uri="mock:result"/>
>>> >> >>         </route>
>>> >> >>     </camelContext>
>>> >> >>
>>> >> >> with mine.
>>> >> >>
>>> >> >> What is different concerns the TransactionManager used.
>>> >> >>
>>> >> >> In the example, this is the Spring one:
>>> >> >>
>>> >> >>     <!-- setup spring jms TX manager -->
>>> >> >>     <bean id="jmsTransactionManager"
>>> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
>>> >> >>         <property name="connectionFactory"
>>> ref="jmsConnectionFactory"/>
>>> >> >>     </bean>
>>> >> >>
>>> >> >> and in my case, ActiveMQ is configured to use Geronimo Transaction
>>> >> Manager
>>> >> >> bundle (which in fact uses spring Transaction manager :
>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>>> >> >>
>>> >> >> I suppose that in the example, the policy is defined by default by
>>> >> spring
>>> >> >> when instantiating the class :
>>> >> >> org.springframework.jms.connection.JmsTransactionManager
>>> >> >>
>>> >> >> Is it possible to do the same using a JtaTransaction manager ?
>>> >> >>
>>> >> >> Regards,
>>> >> >>
>>> >> >> Charles Moulliard
>>> >> >> Senior Enterprise Architect
>>> >> >> Apache Camel Committer
>>> >> >>
>>> >> >> *****************************
>>> >> >> blog : http://cmoulliard.blogspot.com
>>> >> >>
>>> >> >>
>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]>
>>> >> wrote:
>>> >> >>
>>> >> >>> Hi
>>> >> >>>
>>> >> >>> Yeah you need to add all the spring transaction stuff.
>>> >> >>>
>>> >> >>>
>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>>> [hidden email]
>>> >> >
>>> >> >>> wrote:
>>> >> >>> > Camel generates the following error with my route :
>>> >> >>> >
>>> >> >>> > Route
>>> >> >>> >
>>> >> >>> >        <camel:route>
>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message" />
>>> >> >>> >            <camel:transacted/>
>>> >> >>> >            <camel:bean ref="serviceHelper"
>>> >> method="createNotification"
>>> >> >>> />
>>> >> >>> >            <camel:bean ref="serviceHelper" method="generateError"
>>> />
>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>>> >> >>> >        </camel:route>
>>> >> >>> >
>>> >> >>> > It seems that policy must be defined but in the example here it
>>> is
>>> >> not
>>> >> >>> > mentioned : http://camel.apache.org/transactional-client.html
>>> >> >>> >
>>> >> >>> > Error :
>>> >> >>> >
>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
>>> >> >>>    |
>>> >> >>> > BundleApplicationContextListener   50 | Application context
>>> refresh
>>> >> >>> failed
>>> >> >>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>>> >> >>> > org.apache.camel.RuntimeCamelException:
>>> >> >>> java.lang.IllegalArgumentException:
>>> >> >>> > policy must be specified on: Transacted[ref: null]
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
>>> >> specified
>>> >> >>> on:
>>> >> >>> > Transacted[ref: null]
>>> >> >>> >    at
>>> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>>> >> >>> >    at
>>> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>>> >> >>> >    at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>>> >> >>> > Charles Moulliard
>>> >> >>> > Senior Enterprise Architect
>>> >> >>> > Apache Camel Committer
>>> >> >>> >
>>> >> >>> > *****************************
>>> >> >>> > blog : http://cmoulliard.blogspot.com
>>> >> >>> >
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>> --
>>> >> >>> Claus Ibsen
>>> >> >>> Apache Camel Committer
>>> >> >>>
>>> >> >>> Open Source Integration: http://fusesource.com
>>> >> >>> Blog: http://davsclaus.blogspot.com/
>>> >> >>> Twitter: http://twitter.com/davsclaus
>>> >> >>>
>>> >> >>
>>> >> >>
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Claus Ibsen
>>> >> Apache Camel Committer
>>> >>
>>> >> Open Source Integration: http://fusesource.com
>>> >> Blog: http://davsclaus.blogspot.com/
>>> >> Twitter: http://twitter.com/davsclaus
>>> >>
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Claus Ibsen-2
And reconsider if you need XA at all. Its slow and hard to get setup.

Try to let the DB be the last stuff you do and afterwards send the
message to another queue for further processing in a 2nd route.
If that is possible in your use-case.


On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]> wrote:

> Hi
>
> Get it working outside OSGi, eg in a small unit test thats easy to run
> and test from within your IDE.
> Google for JMS + hibernate + TX + XA to find some samples that work.
>
> And since you use JMS + DB in the same TX you need to use XA db driver.
>
> It can be a painful to get setup
> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
>
> And you need an XA TX manager such as JOTM
> http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
>
> In j2ee land there was a JTA with the container that could do it. But
> in your OSGi container I do not know if it provides one out of the
> box.
>
>
> On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<[hidden email]> wrote:
>> I'm still fighting against Spring config or Camel because Rollback does not
>> occur. I have been able to configure Hibernate to use the same
>> TransactionManager as the one used by JMS
>>
>> Here is the different part of the config. I don't know where the issue could
>> be !
>>
>> 1) ActiveMQ
>>
>> ...
>>
>>    <bean id="activemqConnectionFactory"
>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>        <property name="brokerURL" value="tcp://localhost:61616" />
>>    </bean>
>>
>>    <bean id="pooledConnectionFactory"
>> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
>>        <property name="maxConnections" value="8" />
>>        <property name="maximumActive" value="500" />
>>        <property name="transactionManager" ref="transactionManager" />
>>        <property name="connectionFactory" ref="activemqConnectionFactory"
>> />
>>        <property name="resourceName" value="activemq.default" />
>>    </bean>
>>
>>    <bean id="resourceManager"
>> class="org.apache.activemq.pool.ActiveMQResourceManager"
>> init-method="recoverResource">
>>          <property name="transactionManager" ref="transactionManager" />
>>          <property name="connectionFactory" ref="activemqConnectionFactory"
>> />
>>          <property name="resourceName" value="activemq.default" />
>>    </bean>
>>
>>    <osgi:reference id="transactionManager"
>> interface="javax.transaction.TransactionManager" /> // This OSGI service is
>> published by Geronimo Transaction bundle
>>
>>    <osgi:service ref="pooledConnectionFactory">
>>        <osgi:interfaces>
>>            <value>javax.jms.ConnectionFactory</value>
>>        </osgi:interfaces>
>>        <osgi:service-properties>
>>            <entry key="name" value="default"/>
>>        </osgi:service-properties>
>>    </osgi:service>
>>
>> 2) Camel ActiveMQComponent
>>
>>    <bean id="active-mq"
>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>        <property name="transacted" value="true"/>
>>        <property name="connectionFactory">
>>            <osgi:reference interface="javax.jms.ConnectionFactory"/> //
>> OSGI service is published by ActiveMQ service
>>        </property>
>>        <property name="transactionManager">
>>            <osgi:reference
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>        </property>
>>    </bean>
>>
>> 2) Hibernate - DAO
>>
>>    <bean id="sessionFactory"
>> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>>
>>        <property name="mappingLocations">
>>            <list>
>>
>> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
>>            </list>
>>        </property>
>>
>>        <property name="hibernateProperties">
>>            <props>
>>                <prop
>> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>>                <prop key="hibernate.show_sql">true</prop>
>>                <prop key="hibernate.format_sql">true</prop>
>>                <prop
>> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>>                <prop key="hibernate.jdbc.batch_size">10</prop>
>>                <prop
>> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
>>                <prop
>> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
>>            </props>
>>        </property>
>>        <property name="dataSource">
>>            <ref bean="dataSource" />
>>        </property>
>>
>> Remark : To avoid the JNDI lookup issue, we use springTransactionFactory as
>> the TransactionFactory for Hibernate (
>> http://forum.springsource.org/showthread.php?p=215720)
>>
>> 3) Service layer
>>
>> Here is the definition of the service used from Camel route :
>>
>>    <bean id="notificationServiceTarget"
>> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
>>            <property name="notificationDAO">
>>            <osgi:reference
>> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
>>        </property>
>>
>>    </bean>
>>
>>   <!-- Abstract service using the Geronimo Transaction Manager -->
>>    <bean id="abstractService" abstract="true"
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>>         <property name="transactionManager">
>>            <osgi:reference
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>        </property>
>>    </bean>
>>
>>    <bean id="notificationService"
>>          parent="abstractService"
>>
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>>
>>        <property name="target">
>>            <ref bean="notificationServiceTarget" />
>>        </property>
>>
>>        <property name="transactionAttributes">
>>            <props>
>>                <prop key="*">PROPAGATION_REQUIRED</prop>
>>            </props>
>>        </property>
>>    </bean>
>>
>> 4) Route
>>
>>    <bean id="myPolicy" class="org.apache.camel.processor.RedeliveryPolicy">
>>        <property name="maximumRedeliveries" value="1"/>
>>    </bean>
>>
>>    <bean id="txErrorHandler"
>> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>>        <property name="springTransactionPolicy"
>> ref="PROPAGATION_REQUIRED"/>
>>        <property name="redeliveryPolicy" ref="myPolicy"/>
>>    </bean>
>>
>>    <bean id="PROPAGATION_REQUIRED"
>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>        <property name="transactionManager">
>>            <osgi:reference
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>        </property>
>>    </bean>
>>
>>        <camel:route errorHandlerRef="txErrorHandler">
>>            <camel:from ref="queueQuickFixInEndpoint" />
>>            <camel:convertBodyTo type="quickfix.Message" />
>>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>>            <camel:bean ref="serviceHelper" method="createNotification" />
>>            <camel:bean ref="serviceHelper" method="generateError" />
>>            <camel:to ref="directNotificationEndpoint" />
>>        </camel:route>
>>
>> Any ideas are welcome
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <[hidden email]>wrote:
>>
>>> OK. I will try to create my own Hibernate JTATransaction manager as the
>>> existing try to perform a JNDI lookup to find the transaction manager on
>>> OSGI platform (inheritage from J2EE world)
>>>
>>>
>>> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>>>
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>>
>>>
>>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]> wrote:
>>>
>>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<[hidden email]>
>>>> wrote:
>>>> > queueQuickFixInEndpoint is a JMS queue.
>>>> >
>>>> > I will add the ref to the transacted and retest
>>>> >
>>>> > Question : I suppose that rollback will not occur if by example JMS and
>>>> DB
>>>> > (=Hibernate) does not use the same TransactionManager and don't use this
>>>> > spring class together :
>>>> > org.springframework.transaction.PlatformTransactionManager
>>>> Yes they must be configured to use the same TX manager.
>>>>
>>>>
>>>> >
>>>> > Regards,
>>>> >
>>>> > Charles Moulliard
>>>> > Senior Enterprise Architect
>>>> > Apache Camel Committer
>>>> >
>>>> > *****************************
>>>> > blog : http://cmoulliard.blogspot.com
>>>> >
>>>> >
>>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]>
>>>> wrote:
>>>> >
>>>> >> Transacted also have a ref attribute
>>>> >>
>>>> >> <transacted ref="required"/>
>>>> >>
>>>> >> Is queueQuickFixInEndpoint a JMS queue?
>>>> >> You need to use a TX manager that can do both JMS and DB.
>>>> >>
>>>> >>
>>>> >>
>>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<[hidden email]
>>>> >
>>>> >> wrote:
>>>> >> > I have been able to solve my problem by adding the following bean
>>>> >> definition
>>>> >> > :
>>>> >> >
>>>> >> >    <bean id="required"
>>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>>> >> >        <property name="transactionManager">
>>>> >> >            <osgi:reference
>>>> >> >
>>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>>> >> >        </property>
>>>> >> >    </bean>
>>>> >> >
>>>> >> > and in the route
>>>> >> >
>>>> >> >        <camel:route>
>>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>>>> >> >            <camel:transacted/>
>>>> >> >            <camel:policy ref="required" />
>>>> >> >            <camel:bean ref="serviceHelper"
>>>> method="createNotification" />
>>>> >> >            <camel:bean ref="serviceHelper" method="generateError" />
>>>> >> >            <camel:to ref="directNotificationEndpoint" />
>>>> >> >        </camel:route>
>>>> >> >
>>>> >> > Unfortunately, the rollback does not occur in the DB and 6 records
>>>> have
>>>> >> been
>>>> >> > created by the method createNotification when error has been raised
>>>> by
>>>> >> the
>>>> >> > method generateError.
>>>> >> >
>>>> >> > What is missing ?
>>>> >> >
>>>> >> > Charles Moulliard
>>>> >> > Senior Enterprise Architect
>>>> >> > Apache Camel Committer
>>>> >> >
>>>> >> > *****************************
>>>> >> > blog : http://cmoulliard.blogspot.com
>>>> >> >
>>>> >> >
>>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>>>> [hidden email]
>>>> >> >wrote:
>>>> >> >
>>>> >> >> When I compare the example : JMSTransactionalClientRollbackTest.xml
>>>> >> >>
>>>> >> >>     <!-- START SNIPPET: e1 -->
>>>> >> >>     <!-- setup JMS connection factory -->
>>>> >> >>     <bean id="jmsConnectionFactory"
>>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>>>> >> >>         <property name="brokerURL"
>>>> >> >>
>>>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>>>> >> >>     </bean>
>>>> >> >>
>>>> >> >>     <!-- setup spring jms TX manager -->
>>>> >> >>     <bean id="jmsTransactionManager"
>>>> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
>>>> >> >>         <property name="connectionFactory"
>>>> ref="jmsConnectionFactory"/>
>>>> >> >>     </bean>
>>>> >> >>
>>>> >> >>     <!-- define our activemq component -->
>>>> >> >>     <bean id="activemq"
>>>> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>>> >> >>         <property name="connectionFactory"
>>>> ref="jmsConnectionFactory"/>
>>>> >> >>         <!-- define the jms consumer/producer as transacted -->
>>>> >> >>         <property name="transacted" value="true"/>
>>>> >> >>         <!-- setup the transaction manager to use -->
>>>> >> >>         <!-- if not provided then Camel will automatic use a
>>>> >> >> JmsTransactionManager, however if you
>>>> >> >>              for instance use a JTA transaction manager then you
>>>> must
>>>> >> >> configure it -->
>>>> >> >>         <property name="transactionManager"
>>>> >> ref="jmsTransactionManager"/>
>>>> >> >>     </bean>
>>>> >> >>     <!-- END SNIPPET: e1 -->
>>>> >> >>
>>>> >> >>     <!-- START SNIPPET: e2 -->
>>>> >> >>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>>>> >> >>         <route>
>>>> >> >>             <!-- 1: from the jms queue -->
>>>> >> >>             <from uri="activemq:queue:okay"/>
>>>> >> >>             <!-- 2: mark this route as transacted -->
>>>> >> >>             <transacted/>
>>>> >> >>             <!-- 3: call our business logic that is myProcessor -->
>>>> >> >>             <process ref="myProcessor"/>
>>>> >> >>             <!-- 4: if success then send it to the mock -->
>>>> >> >>             <to uri="mock:result"/>
>>>> >> >>         </route>
>>>> >> >>     </camelContext>
>>>> >> >>
>>>> >> >> with mine.
>>>> >> >>
>>>> >> >> What is different concerns the TransactionManager used.
>>>> >> >>
>>>> >> >> In the example, this is the Spring one:
>>>> >> >>
>>>> >> >>     <!-- setup spring jms TX manager -->
>>>> >> >>     <bean id="jmsTransactionManager"
>>>> >> >> class="org.springframework.jms.connection.JmsTransactionManager">
>>>> >> >>         <property name="connectionFactory"
>>>> ref="jmsConnectionFactory"/>
>>>> >> >>     </bean>
>>>> >> >>
>>>> >> >> and in my case, ActiveMQ is configured to use Geronimo Transaction
>>>> >> Manager
>>>> >> >> bundle (which in fact uses spring Transaction manager :
>>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>>>> >> >>
>>>> >> >> I suppose that in the example, the policy is defined by default by
>>>> >> spring
>>>> >> >> when instantiating the class :
>>>> >> >> org.springframework.jms.connection.JmsTransactionManager
>>>> >> >>
>>>> >> >> Is it possible to do the same using a JtaTransaction manager ?
>>>> >> >>
>>>> >> >> Regards,
>>>> >> >>
>>>> >> >> Charles Moulliard
>>>> >> >> Senior Enterprise Architect
>>>> >> >> Apache Camel Committer
>>>> >> >>
>>>> >> >> *****************************
>>>> >> >> blog : http://cmoulliard.blogspot.com
>>>> >> >>
>>>> >> >>
>>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <[hidden email]>
>>>> >> wrote:
>>>> >> >>
>>>> >> >>> Hi
>>>> >> >>>
>>>> >> >>> Yeah you need to add all the spring transaction stuff.
>>>> >> >>>
>>>> >> >>>
>>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>>>> [hidden email]
>>>> >> >
>>>> >> >>> wrote:
>>>> >> >>> > Camel generates the following error with my route :
>>>> >> >>> >
>>>> >> >>> > Route
>>>> >> >>> >
>>>> >> >>> >        <camel:route>
>>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message" />
>>>> >> >>> >            <camel:transacted/>
>>>> >> >>> >            <camel:bean ref="serviceHelper"
>>>> >> method="createNotification"
>>>> >> >>> />
>>>> >> >>> >            <camel:bean ref="serviceHelper" method="generateError"
>>>> />
>>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>>>> >> >>> >        </camel:route>
>>>> >> >>> >
>>>> >> >>> > It seems that policy must be defined but in the example here it
>>>> is
>>>> >> not
>>>> >> >>> > mentioned : http://camel.apache.org/transactional-client.html
>>>> >> >>> >
>>>> >> >>> > Error :
>>>> >> >>> >
>>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 | ContextLoaderListener
>>>> >> >>>    |
>>>> >> >>> > BundleApplicationContextListener   50 | Application context
>>>> refresh
>>>> >> >>> failed
>>>> >> >>> > (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>>>> >> >>> > org.apache.camel.RuntimeCamelException:
>>>> >> >>> java.lang.IllegalArgumentException:
>>>> >> >>> > policy must be specified on: Transacted[ref: null]
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
>>>> >> specified
>>>> >> >>> on:
>>>> >> >>> > Transacted[ref: null]
>>>> >> >>> >    at
>>>> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>>>> >> >>> >    at
>>>> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>>>> >> >>> >    at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>>>> >> >>> > Charles Moulliard
>>>> >> >>> > Senior Enterprise Architect
>>>> >> >>> > Apache Camel Committer
>>>> >> >>> >
>>>> >> >>> > *****************************
>>>> >> >>> > blog : http://cmoulliard.blogspot.com
>>>> >> >>> >
>>>> >> >>>
>>>> >> >>>
>>>> >> >>>
>>>> >> >>> --
>>>> >> >>> Claus Ibsen
>>>> >> >>> Apache Camel Committer
>>>> >> >>>
>>>> >> >>> Open Source Integration: http://fusesource.com
>>>> >> >>> Blog: http://davsclaus.blogspot.com/
>>>> >> >>> Twitter: http://twitter.com/davsclaus
>>>> >> >>>
>>>> >> >>
>>>> >> >>
>>>> >> >
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Claus Ibsen
>>>> >> Apache Camel Committer
>>>> >>
>>>> >> Open Source Integration: http://fusesource.com
>>>> >> Blog: http://davsclaus.blogspot.com/
>>>> >> Twitter: http://twitter.com/davsclaus
>>>> >>
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>>
>>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
Claus,

I don't want at all to use XA transaction. Correct me if I'm wrong but the
example of the documentation (Camel 2.0 - JMS Sample - part Spring XML) does
not use at all a XA driver and the message will not be removed from the
queue if a rollback occurs in the bean MyProcessor ?

My concern is to avoid to lost messages from a file, queues if something
happen in one of the services called where by example we have to save data
in a DB or generate a report for a client. If such errors occur, then we
have to investigate why can't save data in DB (maybe related to a connection
issue, DB shutdown, ...) or generates files (maybe due to disk full, access
right, ....). Sometimes, this is related to conditions out of the control of
our application but sometimes no, then we have to correct the error and
install a new version of the code. After the restart of the application and
recovery of messages (persisted in the case of activemq), messages will be
reprocessed.

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]> wrote:

> And reconsider if you need XA at all. Its slow and hard to get setup.
>
> Try to let the DB be the last stuff you do and afterwards send the
> message to another queue for further processing in a 2nd route.
> If that is possible in your use-case.
>
>
> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]> wrote:
> > Hi
> >
> > Get it working outside OSGi, eg in a small unit test thats easy to run
> > and test from within your IDE.
> > Google for JMS + hibernate + TX + XA to find some samples that work.
> >
> > And since you use JMS + DB in the same TX you need to use XA db driver.
> >
> > It can be a painful to get setup
> >
> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
> >
> > And you need an XA TX manager such as JOTM
> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
> >
> > In j2ee land there was a JTA with the container that could do it. But
> > in your OSGi container I do not know if it provides one out of the
> > box.
> >
> >
> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<[hidden email]>
> wrote:
> >> I'm still fighting against Spring config or Camel because Rollback does
> not
> >> occur. I have been able to configure Hibernate to use the same
> >> TransactionManager as the one used by JMS
> >>
> >> Here is the different part of the config. I don't know where the issue
> could
> >> be !
> >>
> >> 1) ActiveMQ
> >>
> >> ...
> >>
> >>    <bean id="activemqConnectionFactory"
> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >>        <property name="brokerURL" value="tcp://localhost:61616" />
> >>    </bean>
> >>
> >>    <bean id="pooledConnectionFactory"
> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
> >>        <property name="maxConnections" value="8" />
> >>        <property name="maximumActive" value="500" />
> >>        <property name="transactionManager" ref="transactionManager" />
> >>        <property name="connectionFactory"
> ref="activemqConnectionFactory"
> >> />
> >>        <property name="resourceName" value="activemq.default" />
> >>    </bean>
> >>
> >>    <bean id="resourceManager"
> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
> >> init-method="recoverResource">
> >>          <property name="transactionManager" ref="transactionManager" />
> >>          <property name="connectionFactory"
> ref="activemqConnectionFactory"
> >> />
> >>          <property name="resourceName" value="activemq.default" />
> >>    </bean>
> >>
> >>    <osgi:reference id="transactionManager"
> >> interface="javax.transaction.TransactionManager" /> // This OSGI service
> is
> >> published by Geronimo Transaction bundle
> >>
> >>    <osgi:service ref="pooledConnectionFactory">
> >>        <osgi:interfaces>
> >>            <value>javax.jms.ConnectionFactory</value>
> >>        </osgi:interfaces>
> >>        <osgi:service-properties>
> >>            <entry key="name" value="default"/>
> >>        </osgi:service-properties>
> >>    </osgi:service>
> >>
> >> 2) Camel ActiveMQComponent
> >>
> >>    <bean id="active-mq"
> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >>        <property name="transacted" value="true"/>
> >>        <property name="connectionFactory">
> >>            <osgi:reference interface="javax.jms.ConnectionFactory"/> //
> >> OSGI service is published by ActiveMQ service
> >>        </property>
> >>        <property name="transactionManager">
> >>            <osgi:reference
> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>        </property>
> >>    </bean>
> >>
> >> 2) Hibernate - DAO
> >>
> >>    <bean id="sessionFactory"
> >> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> >>
> >>        <property name="mappingLocations">
> >>            <list>
> >>
> >>
> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
> >>            </list>
> >>        </property>
> >>
> >>        <property name="hibernateProperties">
> >>            <props>
> >>                <prop
> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
> >>                <prop key="hibernate.show_sql">true</prop>
> >>                <prop key="hibernate.format_sql">true</prop>
> >>                <prop
> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
> >>                <prop
> >>
> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
> >>                <prop
> >>
> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
> >>            </props>
> >>        </property>
> >>        <property name="dataSource">
> >>            <ref bean="dataSource" />
> >>        </property>
> >>
> >> Remark : To avoid the JNDI lookup issue, we use springTransactionFactory
> as
> >> the TransactionFactory for Hibernate (
> >> http://forum.springsource.org/showthread.php?p=215720)
> >>
> >> 3) Service layer
> >>
> >> Here is the definition of the service used from Camel route :
> >>
> >>    <bean id="notificationServiceTarget"
> >> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
> >>            <property name="notificationDAO">
> >>            <osgi:reference
> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
> >>        </property>
> >>
> >>    </bean>
> >>
> >>   <!-- Abstract service using the Geronimo Transaction Manager -->
> >>    <bean id="abstractService" abstract="true"
> >>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
> >>         <property name="transactionManager">
> >>            <osgi:reference
> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>        </property>
> >>    </bean>
> >>
> >>    <bean id="notificationService"
> >>          parent="abstractService"
> >>
> >>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
> >>
> >>        <property name="target">
> >>            <ref bean="notificationServiceTarget" />
> >>        </property>
> >>
> >>        <property name="transactionAttributes">
> >>            <props>
> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
> >>            </props>
> >>        </property>
> >>    </bean>
> >>
> >> 4) Route
> >>
> >>    <bean id="myPolicy"
> class="org.apache.camel.processor.RedeliveryPolicy">
> >>        <property name="maximumRedeliveries" value="1"/>
> >>    </bean>
> >>
> >>    <bean id="txErrorHandler"
> >> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
> >>        <property name="springTransactionPolicy"
> >> ref="PROPAGATION_REQUIRED"/>
> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
> >>    </bean>
> >>
> >>    <bean id="PROPAGATION_REQUIRED"
> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >>        <property name="transactionManager">
> >>            <osgi:reference
> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>        </property>
> >>    </bean>
> >>
> >>        <camel:route errorHandlerRef="txErrorHandler">
> >>            <camel:from ref="queueQuickFixInEndpoint" />
> >>            <camel:convertBodyTo type="quickfix.Message" />
> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
> >>            <camel:bean ref="serviceHelper" method="createNotification"
> />
> >>            <camel:bean ref="serviceHelper" method="generateError" />
> >>            <camel:to ref="directNotificationEndpoint" />
> >>        </camel:route>
> >>
> >> Any ideas are welcome
> >>
> >> Regards,
> >>
> >> Charles Moulliard
> >> Senior Enterprise Architect
> >> Apache Camel Committer
> >>
> >> *****************************
> >> blog : http://cmoulliard.blogspot.com
> >>
> >>
> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <[hidden email]
> >wrote:
> >>
> >>> OK. I will try to create my own Hibernate JTATransaction manager as the
> >>> existing try to perform a JNDI lookup to find the transaction manager
> on
> >>> OSGI platform (inheritage from J2EE world)
> >>>
> >>>
> >>>
> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
> >>>
> >>>
> >>> Charles Moulliard
> >>> Senior Enterprise Architect
> >>> Apache Camel Committer
> >>>
> >>> *****************************
> >>> blog : http://cmoulliard.blogspot.com
> >>>
> >>>
> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]>
> wrote:
> >>>
> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> [hidden email]>
> >>>> wrote:
> >>>> > queueQuickFixInEndpoint is a JMS queue.
> >>>> >
> >>>> > I will add the ref to the transacted and retest
> >>>> >
> >>>> > Question : I suppose that rollback will not occur if by example JMS
> and
> >>>> DB
> >>>> > (=Hibernate) does not use the same TransactionManager and don't use
> this
> >>>> > spring class together :
> >>>> > org.springframework.transaction.PlatformTransactionManager
> >>>> Yes they must be configured to use the same TX manager.
> >>>>
> >>>>
> >>>> >
> >>>> > Regards,
> >>>> >
> >>>> > Charles Moulliard
> >>>> > Senior Enterprise Architect
> >>>> > Apache Camel Committer
> >>>> >
> >>>> > *****************************
> >>>> > blog : http://cmoulliard.blogspot.com
> >>>> >
> >>>> >
> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]>
> >>>> wrote:
> >>>> >
> >>>> >> Transacted also have a ref attribute
> >>>> >>
> >>>> >> <transacted ref="required"/>
> >>>> >>
> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
> >>>> >> You need to use a TX manager that can do both JMS and DB.
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
> [hidden email]
> >>>> >
> >>>> >> wrote:
> >>>> >> > I have been able to solve my problem by adding the following bean
> >>>> >> definition
> >>>> >> > :
> >>>> >> >
> >>>> >> >    <bean id="required"
> >>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >>>> >> >        <property name="transactionManager">
> >>>> >> >            <osgi:reference
> >>>> >> >
> >>>>
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>>> >> >        </property>
> >>>> >> >    </bean>
> >>>> >> >
> >>>> >> > and in the route
> >>>> >> >
> >>>> >> >        <camel:route>
> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
> >>>> >> >            <camel:transacted/>
> >>>> >> >            <camel:policy ref="required" />
> >>>> >> >            <camel:bean ref="serviceHelper"
> >>>> method="createNotification" />
> >>>> >> >            <camel:bean ref="serviceHelper" method="generateError"
> />
> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
> >>>> >> >        </camel:route>
> >>>> >> >
> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
> records
> >>>> have
> >>>> >> been
> >>>> >> > created by the method createNotification when error has been
> raised
> >>>> by
> >>>> >> the
> >>>> >> > method generateError.
> >>>> >> >
> >>>> >> > What is missing ?
> >>>> >> >
> >>>> >> > Charles Moulliard
> >>>> >> > Senior Enterprise Architect
> >>>> >> > Apache Camel Committer
> >>>> >> >
> >>>> >> > *****************************
> >>>> >> > blog : http://cmoulliard.blogspot.com
> >>>> >> >
> >>>> >> >
> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
> >>>> [hidden email]
> >>>> >> >wrote:
> >>>> >> >
> >>>> >> >> When I compare the example :
> JMSTransactionalClientRollbackTest.xml
> >>>> >> >>
> >>>> >> >>     <!-- START SNIPPET: e1 -->
> >>>> >> >>     <!-- setup JMS connection factory -->
> >>>> >> >>     <bean id="jmsConnectionFactory"
> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >>>> >> >>         <property name="brokerURL"
> >>>> >> >>
> >>>>
> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
> >>>> >> >>     </bean>
> >>>> >> >>
> >>>> >> >>     <!-- setup spring jms TX manager -->
> >>>> >> >>     <bean id="jmsTransactionManager"
> >>>> >> >>
> class="org.springframework.jms.connection.JmsTransactionManager">
> >>>> >> >>         <property name="connectionFactory"
> >>>> ref="jmsConnectionFactory"/>
> >>>> >> >>     </bean>
> >>>> >> >>
> >>>> >> >>     <!-- define our activemq component -->
> >>>> >> >>     <bean id="activemq"
> >>>> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >>>> >> >>         <property name="connectionFactory"
> >>>> ref="jmsConnectionFactory"/>
> >>>> >> >>         <!-- define the jms consumer/producer as transacted -->
> >>>> >> >>         <property name="transacted" value="true"/>
> >>>> >> >>         <!-- setup the transaction manager to use -->
> >>>> >> >>         <!-- if not provided then Camel will automatic use a
> >>>> >> >> JmsTransactionManager, however if you
> >>>> >> >>              for instance use a JTA transaction manager then you
> >>>> must
> >>>> >> >> configure it -->
> >>>> >> >>         <property name="transactionManager"
> >>>> >> ref="jmsTransactionManager"/>
> >>>> >> >>     </bean>
> >>>> >> >>     <!-- END SNIPPET: e1 -->
> >>>> >> >>
> >>>> >> >>     <!-- START SNIPPET: e2 -->
> >>>> >> >>     <camelContext xmlns="http://camel.apache.org/schema/spring
> ">
> >>>> >> >>         <route>
> >>>> >> >>             <!-- 1: from the jms queue -->
> >>>> >> >>             <from uri="activemq:queue:okay"/>
> >>>> >> >>             <!-- 2: mark this route as transacted -->
> >>>> >> >>             <transacted/>
> >>>> >> >>             <!-- 3: call our business logic that is myProcessor
> -->
> >>>> >> >>             <process ref="myProcessor"/>
> >>>> >> >>             <!-- 4: if success then send it to the mock -->
> >>>> >> >>             <to uri="mock:result"/>
> >>>> >> >>         </route>
> >>>> >> >>     </camelContext>
> >>>> >> >>
> >>>> >> >> with mine.
> >>>> >> >>
> >>>> >> >> What is different concerns the TransactionManager used.
> >>>> >> >>
> >>>> >> >> In the example, this is the Spring one:
> >>>> >> >>
> >>>> >> >>     <!-- setup spring jms TX manager -->
> >>>> >> >>     <bean id="jmsTransactionManager"
> >>>> >> >>
> class="org.springframework.jms.connection.JmsTransactionManager">
> >>>> >> >>         <property name="connectionFactory"
> >>>> ref="jmsConnectionFactory"/>
> >>>> >> >>     </bean>
> >>>> >> >>
> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
> Transaction
> >>>> >> Manager
> >>>> >> >> bundle (which in fact uses spring Transaction manager :
> >>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
> >>>> >> >>
> >>>> >> >> I suppose that in the example, the policy is defined by default
> by
> >>>> >> spring
> >>>> >> >> when instantiating the class :
> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
> >>>> >> >>
> >>>> >> >> Is it possible to do the same using a JtaTransaction manager ?
> >>>> >> >>
> >>>> >> >> Regards,
> >>>> >> >>
> >>>> >> >> Charles Moulliard
> >>>> >> >> Senior Enterprise Architect
> >>>> >> >> Apache Camel Committer
> >>>> >> >>
> >>>> >> >> *****************************
> >>>> >> >> blog : http://cmoulliard.blogspot.com
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
> [hidden email]>
> >>>> >> wrote:
> >>>> >> >>
> >>>> >> >>> Hi
> >>>> >> >>>
> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
> >>>> [hidden email]
> >>>> >> >
> >>>> >> >>> wrote:
> >>>> >> >>> > Camel generates the following error with my route :
> >>>> >> >>> >
> >>>> >> >>> > Route
> >>>> >> >>> >
> >>>> >> >>> >        <camel:route>
> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
> >>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message" />
> >>>> >> >>> >            <camel:transacted/>
> >>>> >> >>> >            <camel:bean ref="serviceHelper"
> >>>> >> method="createNotification"
> >>>> >> >>> />
> >>>> >> >>> >            <camel:bean ref="serviceHelper"
> method="generateError"
> >>>> />
> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
> >>>> >> >>> >        </camel:route>
> >>>> >> >>> >
> >>>> >> >>> > It seems that policy must be defined but in the example here
> it
> >>>> is
> >>>> >> not
> >>>> >> >>> > mentioned :
> http://camel.apache.org/transactional-client.html
> >>>> >> >>> >
> >>>> >> >>> > Error :
> >>>> >> >>> >
> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
> ContextLoaderListener
> >>>> >> >>>    |
> >>>> >> >>> > BundleApplicationContextListener   50 | Application context
> >>>> refresh
> >>>> >> >>> failed
> >>>> >> >>> >
> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
> >>>> >> >>> java.lang.IllegalArgumentException:
> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
> >>>> >> specified
> >>>> >> >>> on:
> >>>> >> >>> > Transacted[ref: null]
> >>>> >> >>> >    at
> >>>> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
> >>>> >> >>> >    at
> >>>> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
> >>>> >> >>> >    at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> >>>> >> >>> > Charles Moulliard
> >>>> >> >>> > Senior Enterprise Architect
> >>>> >> >>> > Apache Camel Committer
> >>>> >> >>> >
> >>>> >> >>> > *****************************
> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>> --
> >>>> >> >>> Claus Ibsen
> >>>> >> >>> Apache Camel Committer
> >>>> >> >>>
> >>>> >> >>> Open Source Integration: http://fusesource.com
> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
> >>>> >> >>> Twitter: http://twitter.com/davsclaus
> >>>> >> >>>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> --
> >>>> >> Claus Ibsen
> >>>> >> Apache Camel Committer
> >>>> >>
> >>>> >> Open Source Integration: http://fusesource.com
> >>>> >> Blog: http://davsclaus.blogspot.com/
> >>>> >> Twitter: http://twitter.com/davsclaus
> >>>> >>
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Claus Ibsen
> >>>> Apache Camel Committer
> >>>>
> >>>> Open Source Integration: http://fusesource.com
> >>>> Blog: http://davsclaus.blogspot.com/
> >>>> Twitter: http://twitter.com/davsclaus
> >>>>
> >>>
> >>>
> >>
> >
> >
> >
> > --
> > Claus Ibsen
> > Apache Camel Committer
> >
> > Open Source Integration: http://fusesource.com
> > Blog: http://davsclaus.blogspot.com/
> > Twitter: http://twitter.com/davsclaus
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Guillaume Nodet
Administrator
In this case, you should not use transactions for the DB at all, but
if any error occurs while saving the data, an exception should be
thrown and should rollback the transaction for the JMS layer.

On Fri, Jul 3, 2009 at 10:48, Charles Moulliard<[hidden email]> wrote:

> Claus,
>
> I don't want at all to use XA transaction. Correct me if I'm wrong but the
> example of the documentation (Camel 2.0 - JMS Sample - part Spring XML) does
> not use at all a XA driver and the message will not be removed from the
> queue if a rollback occurs in the bean MyProcessor ?
>
> My concern is to avoid to lost messages from a file, queues if something
> happen in one of the services called where by example we have to save data
> in a DB or generate a report for a client. If such errors occur, then we
> have to investigate why can't save data in DB (maybe related to a connection
> issue, DB shutdown, ...) or generates files (maybe due to disk full, access
> right, ....). Sometimes, this is related to conditions out of the control of
> our application but sometimes no, then we have to correct the error and
> install a new version of the code. After the restart of the application and
> recovery of messages (persisted in the case of activemq), messages will be
> reprocessed.
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]> wrote:
>
>> And reconsider if you need XA at all. Its slow and hard to get setup.
>>
>> Try to let the DB be the last stuff you do and afterwards send the
>> message to another queue for further processing in a 2nd route.
>> If that is possible in your use-case.
>>
>>
>> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]> wrote:
>> > Hi
>> >
>> > Get it working outside OSGi, eg in a small unit test thats easy to run
>> > and test from within your IDE.
>> > Google for JMS + hibernate + TX + XA to find some samples that work.
>> >
>> > And since you use JMS + DB in the same TX you need to use XA db driver.
>> >
>> > It can be a painful to get setup
>> >
>> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
>> >
>> > And you need an XA TX manager such as JOTM
>> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
>> >
>> > In j2ee land there was a JTA with the container that could do it. But
>> > in your OSGi container I do not know if it provides one out of the
>> > box.
>> >
>> >
>> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<[hidden email]>
>> wrote:
>> >> I'm still fighting against Spring config or Camel because Rollback does
>> not
>> >> occur. I have been able to configure Hibernate to use the same
>> >> TransactionManager as the one used by JMS
>> >>
>> >> Here is the different part of the config. I don't know where the issue
>> could
>> >> be !
>> >>
>> >> 1) ActiveMQ
>> >>
>> >> ...
>> >>
>> >>    <bean id="activemqConnectionFactory"
>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >>        <property name="brokerURL" value="tcp://localhost:61616" />
>> >>    </bean>
>> >>
>> >>    <bean id="pooledConnectionFactory"
>> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
>> >>        <property name="maxConnections" value="8" />
>> >>        <property name="maximumActive" value="500" />
>> >>        <property name="transactionManager" ref="transactionManager" />
>> >>        <property name="connectionFactory"
>> ref="activemqConnectionFactory"
>> >> />
>> >>        <property name="resourceName" value="activemq.default" />
>> >>    </bean>
>> >>
>> >>    <bean id="resourceManager"
>> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
>> >> init-method="recoverResource">
>> >>          <property name="transactionManager" ref="transactionManager" />
>> >>          <property name="connectionFactory"
>> ref="activemqConnectionFactory"
>> >> />
>> >>          <property name="resourceName" value="activemq.default" />
>> >>    </bean>
>> >>
>> >>    <osgi:reference id="transactionManager"
>> >> interface="javax.transaction.TransactionManager" /> // This OSGI service
>> is
>> >> published by Geronimo Transaction bundle
>> >>
>> >>    <osgi:service ref="pooledConnectionFactory">
>> >>        <osgi:interfaces>
>> >>            <value>javax.jms.ConnectionFactory</value>
>> >>        </osgi:interfaces>
>> >>        <osgi:service-properties>
>> >>            <entry key="name" value="default"/>
>> >>        </osgi:service-properties>
>> >>    </osgi:service>
>> >>
>> >> 2) Camel ActiveMQComponent
>> >>
>> >>    <bean id="active-mq"
>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >>        <property name="transacted" value="true"/>
>> >>        <property name="connectionFactory">
>> >>            <osgi:reference interface="javax.jms.ConnectionFactory"/> //
>> >> OSGI service is published by ActiveMQ service
>> >>        </property>
>> >>        <property name="transactionManager">
>> >>            <osgi:reference
>> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>        </property>
>> >>    </bean>
>> >>
>> >> 2) Hibernate - DAO
>> >>
>> >>    <bean id="sessionFactory"
>> >> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>> >>
>> >>        <property name="mappingLocations">
>> >>            <list>
>> >>
>> >>
>> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
>> >>            </list>
>> >>        </property>
>> >>
>> >>        <property name="hibernateProperties">
>> >>            <props>
>> >>                <prop
>> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>> >>                <prop key="hibernate.show_sql">true</prop>
>> >>                <prop key="hibernate.format_sql">true</prop>
>> >>                <prop
>> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
>> >>                <prop
>> >>
>> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
>> >>                <prop
>> >>
>> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
>> >>            </props>
>> >>        </property>
>> >>        <property name="dataSource">
>> >>            <ref bean="dataSource" />
>> >>        </property>
>> >>
>> >> Remark : To avoid the JNDI lookup issue, we use springTransactionFactory
>> as
>> >> the TransactionFactory for Hibernate (
>> >> http://forum.springsource.org/showthread.php?p=215720)
>> >>
>> >> 3) Service layer
>> >>
>> >> Here is the definition of the service used from Camel route :
>> >>
>> >>    <bean id="notificationServiceTarget"
>> >> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
>> >>            <property name="notificationDAO">
>> >>            <osgi:reference
>> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
>> >>        </property>
>> >>
>> >>    </bean>
>> >>
>> >>   <!-- Abstract service using the Geronimo Transaction Manager -->
>> >>    <bean id="abstractService" abstract="true"
>> >>
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>> >>         <property name="transactionManager">
>> >>            <osgi:reference
>> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>        </property>
>> >>    </bean>
>> >>
>> >>    <bean id="notificationService"
>> >>          parent="abstractService"
>> >>
>> >>
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>> >>
>> >>        <property name="target">
>> >>            <ref bean="notificationServiceTarget" />
>> >>        </property>
>> >>
>> >>        <property name="transactionAttributes">
>> >>            <props>
>> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
>> >>            </props>
>> >>        </property>
>> >>    </bean>
>> >>
>> >> 4) Route
>> >>
>> >>    <bean id="myPolicy"
>> class="org.apache.camel.processor.RedeliveryPolicy">
>> >>        <property name="maximumRedeliveries" value="1"/>
>> >>    </bean>
>> >>
>> >>    <bean id="txErrorHandler"
>> >> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>> >>        <property name="springTransactionPolicy"
>> >> ref="PROPAGATION_REQUIRED"/>
>> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
>> >>    </bean>
>> >>
>> >>    <bean id="PROPAGATION_REQUIRED"
>> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >>        <property name="transactionManager">
>> >>            <osgi:reference
>> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>        </property>
>> >>    </bean>
>> >>
>> >>        <camel:route errorHandlerRef="txErrorHandler">
>> >>            <camel:from ref="queueQuickFixInEndpoint" />
>> >>            <camel:convertBodyTo type="quickfix.Message" />
>> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>> >>            <camel:bean ref="serviceHelper" method="createNotification"
>> />
>> >>            <camel:bean ref="serviceHelper" method="generateError" />
>> >>            <camel:to ref="directNotificationEndpoint" />
>> >>        </camel:route>
>> >>
>> >> Any ideas are welcome
>> >>
>> >> Regards,
>> >>
>> >> Charles Moulliard
>> >> Senior Enterprise Architect
>> >> Apache Camel Committer
>> >>
>> >> *****************************
>> >> blog : http://cmoulliard.blogspot.com
>> >>
>> >>
>> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <[hidden email]
>> >wrote:
>> >>
>> >>> OK. I will try to create my own Hibernate JTATransaction manager as the
>> >>> existing try to perform a JNDI lookup to find the transaction manager
>> on
>> >>> OSGI platform (inheritage from J2EE world)
>> >>>
>> >>>
>> >>>
>> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>> >>>
>> >>>
>> >>> Charles Moulliard
>> >>> Senior Enterprise Architect
>> >>> Apache Camel Committer
>> >>>
>> >>> *****************************
>> >>> blog : http://cmoulliard.blogspot.com
>> >>>
>> >>>
>> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]>
>> wrote:
>> >>>
>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>> [hidden email]>
>> >>>> wrote:
>> >>>> > queueQuickFixInEndpoint is a JMS queue.
>> >>>> >
>> >>>> > I will add the ref to the transacted and retest
>> >>>> >
>> >>>> > Question : I suppose that rollback will not occur if by example JMS
>> and
>> >>>> DB
>> >>>> > (=Hibernate) does not use the same TransactionManager and don't use
>> this
>> >>>> > spring class together :
>> >>>> > org.springframework.transaction.PlatformTransactionManager
>> >>>> Yes they must be configured to use the same TX manager.
>> >>>>
>> >>>>
>> >>>> >
>> >>>> > Regards,
>> >>>> >
>> >>>> > Charles Moulliard
>> >>>> > Senior Enterprise Architect
>> >>>> > Apache Camel Committer
>> >>>> >
>> >>>> > *****************************
>> >>>> > blog : http://cmoulliard.blogspot.com
>> >>>> >
>> >>>> >
>> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]>
>> >>>> wrote:
>> >>>> >
>> >>>> >> Transacted also have a ref attribute
>> >>>> >>
>> >>>> >> <transacted ref="required"/>
>> >>>> >>
>> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
>> >>>> >> You need to use a TX manager that can do both JMS and DB.
>> >>>> >>
>> >>>> >>
>> >>>> >>
>> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
>> [hidden email]
>> >>>> >
>> >>>> >> wrote:
>> >>>> >> > I have been able to solve my problem by adding the following bean
>> >>>> >> definition
>> >>>> >> > :
>> >>>> >> >
>> >>>> >> >    <bean id="required"
>> >>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >>>> >> >        <property name="transactionManager">
>> >>>> >> >            <osgi:reference
>> >>>> >> >
>> >>>>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>>> >> >        </property>
>> >>>> >> >    </bean>
>> >>>> >> >
>> >>>> >> > and in the route
>> >>>> >> >
>> >>>> >> >        <camel:route>
>> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>> >>>> >> >            <camel:transacted/>
>> >>>> >> >            <camel:policy ref="required" />
>> >>>> >> >            <camel:bean ref="serviceHelper"
>> >>>> method="createNotification" />
>> >>>> >> >            <camel:bean ref="serviceHelper" method="generateError"
>> />
>> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
>> >>>> >> >        </camel:route>
>> >>>> >> >
>> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
>> records
>> >>>> have
>> >>>> >> been
>> >>>> >> > created by the method createNotification when error has been
>> raised
>> >>>> by
>> >>>> >> the
>> >>>> >> > method generateError.
>> >>>> >> >
>> >>>> >> > What is missing ?
>> >>>> >> >
>> >>>> >> > Charles Moulliard
>> >>>> >> > Senior Enterprise Architect
>> >>>> >> > Apache Camel Committer
>> >>>> >> >
>> >>>> >> > *****************************
>> >>>> >> > blog : http://cmoulliard.blogspot.com
>> >>>> >> >
>> >>>> >> >
>> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>> >>>> [hidden email]
>> >>>> >> >wrote:
>> >>>> >> >
>> >>>> >> >> When I compare the example :
>> JMSTransactionalClientRollbackTest.xml
>> >>>> >> >>
>> >>>> >> >>     <!-- START SNIPPET: e1 -->
>> >>>> >> >>     <!-- setup JMS connection factory -->
>> >>>> >> >>     <bean id="jmsConnectionFactory"
>> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >>>> >> >>         <property name="brokerURL"
>> >>>> >> >>
>> >>>>
>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>> >>>> >> >>     </bean>
>> >>>> >> >>
>> >>>> >> >>     <!-- setup spring jms TX manager -->
>> >>>> >> >>     <bean id="jmsTransactionManager"
>> >>>> >> >>
>> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>>> >> >>         <property name="connectionFactory"
>> >>>> ref="jmsConnectionFactory"/>
>> >>>> >> >>     </bean>
>> >>>> >> >>
>> >>>> >> >>     <!-- define our activemq component -->
>> >>>> >> >>     <bean id="activemq"
>> >>>> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >>>> >> >>         <property name="connectionFactory"
>> >>>> ref="jmsConnectionFactory"/>
>> >>>> >> >>         <!-- define the jms consumer/producer as transacted -->
>> >>>> >> >>         <property name="transacted" value="true"/>
>> >>>> >> >>         <!-- setup the transaction manager to use -->
>> >>>> >> >>         <!-- if not provided then Camel will automatic use a
>> >>>> >> >> JmsTransactionManager, however if you
>> >>>> >> >>              for instance use a JTA transaction manager then you
>> >>>> must
>> >>>> >> >> configure it -->
>> >>>> >> >>         <property name="transactionManager"
>> >>>> >> ref="jmsTransactionManager"/>
>> >>>> >> >>     </bean>
>> >>>> >> >>     <!-- END SNIPPET: e1 -->
>> >>>> >> >>
>> >>>> >> >>     <!-- START SNIPPET: e2 -->
>> >>>> >> >>     <camelContext xmlns="http://camel.apache.org/schema/spring
>> ">
>> >>>> >> >>         <route>
>> >>>> >> >>             <!-- 1: from the jms queue -->
>> >>>> >> >>             <from uri="activemq:queue:okay"/>
>> >>>> >> >>             <!-- 2: mark this route as transacted -->
>> >>>> >> >>             <transacted/>
>> >>>> >> >>             <!-- 3: call our business logic that is myProcessor
>> -->
>> >>>> >> >>             <process ref="myProcessor"/>
>> >>>> >> >>             <!-- 4: if success then send it to the mock -->
>> >>>> >> >>             <to uri="mock:result"/>
>> >>>> >> >>         </route>
>> >>>> >> >>     </camelContext>
>> >>>> >> >>
>> >>>> >> >> with mine.
>> >>>> >> >>
>> >>>> >> >> What is different concerns the TransactionManager used.
>> >>>> >> >>
>> >>>> >> >> In the example, this is the Spring one:
>> >>>> >> >>
>> >>>> >> >>     <!-- setup spring jms TX manager -->
>> >>>> >> >>     <bean id="jmsTransactionManager"
>> >>>> >> >>
>> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>>> >> >>         <property name="connectionFactory"
>> >>>> ref="jmsConnectionFactory"/>
>> >>>> >> >>     </bean>
>> >>>> >> >>
>> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
>> Transaction
>> >>>> >> Manager
>> >>>> >> >> bundle (which in fact uses spring Transaction manager :
>> >>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>> >>>> >> >>
>> >>>> >> >> I suppose that in the example, the policy is defined by default
>> by
>> >>>> >> spring
>> >>>> >> >> when instantiating the class :
>> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
>> >>>> >> >>
>> >>>> >> >> Is it possible to do the same using a JtaTransaction manager ?
>> >>>> >> >>
>> >>>> >> >> Regards,
>> >>>> >> >>
>> >>>> >> >> Charles Moulliard
>> >>>> >> >> Senior Enterprise Architect
>> >>>> >> >> Apache Camel Committer
>> >>>> >> >>
>> >>>> >> >> *****************************
>> >>>> >> >> blog : http://cmoulliard.blogspot.com
>> >>>> >> >>
>> >>>> >> >>
>> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
>> [hidden email]>
>> >>>> >> wrote:
>> >>>> >> >>
>> >>>> >> >>> Hi
>> >>>> >> >>>
>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
>> >>>> >> >>>
>> >>>> >> >>>
>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>> >>>> [hidden email]
>> >>>> >> >
>> >>>> >> >>> wrote:
>> >>>> >> >>> > Camel generates the following error with my route :
>> >>>> >> >>> >
>> >>>> >> >>> > Route
>> >>>> >> >>> >
>> >>>> >> >>> >        <camel:route>
>> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message" />
>> >>>> >> >>> >            <camel:transacted/>
>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>> >>>> >> method="createNotification"
>> >>>> >> >>> />
>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>> method="generateError"
>> >>>> />
>> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>> >>>> >> >>> >        </camel:route>
>> >>>> >> >>> >
>> >>>> >> >>> > It seems that policy must be defined but in the example here
>> it
>> >>>> is
>> >>>> >> not
>> >>>> >> >>> > mentioned :
>> http://camel.apache.org/transactional-client.html
>> >>>> >> >>> >
>> >>>> >> >>> > Error :
>> >>>> >> >>> >
>> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
>> ContextLoaderListener
>> >>>> >> >>>    |
>> >>>> >> >>> > BundleApplicationContextListener   50 | Application context
>> >>>> refresh
>> >>>> >> >>> failed
>> >>>> >> >>> >
>> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
>> >>>> >> >>> java.lang.IllegalArgumentException:
>> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
>> >>>> >> specified
>> >>>> >> >>> on:
>> >>>> >> >>> > Transacted[ref: null]
>> >>>> >> >>> >    at
>> >>>> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>> >>>> >> >>> >    at
>> >>>> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>> >>>> >> >>> >    at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>> >>>> >> >>> > Charles Moulliard
>> >>>> >> >>> > Senior Enterprise Architect
>> >>>> >> >>> > Apache Camel Committer
>> >>>> >> >>> >
>> >>>> >> >>> > *****************************
>> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >> >>>
>> >>>> >> >>>
>> >>>> >> >>> --
>> >>>> >> >>> Claus Ibsen
>> >>>> >> >>> Apache Camel Committer
>> >>>> >> >>>
>> >>>> >> >>> Open Source Integration: http://fusesource.com
>> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
>> >>>> >> >>> Twitter: http://twitter.com/davsclaus
>> >>>> >> >>>
>> >>>> >> >>
>> >>>> >> >>
>> >>>> >> >
>> >>>> >>
>> >>>> >>
>> >>>> >>
>> >>>> >> --
>> >>>> >> Claus Ibsen
>> >>>> >> Apache Camel Committer
>> >>>> >>
>> >>>> >> Open Source Integration: http://fusesource.com
>> >>>> >> Blog: http://davsclaus.blogspot.com/
>> >>>> >> Twitter: http://twitter.com/davsclaus
>> >>>> >>
>> >>>> >
>> >>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> Claus Ibsen
>> >>>> Apache Camel Committer
>> >>>>
>> >>>> Open Source Integration: http://fusesource.com
>> >>>> Blog: http://davsclaus.blogspot.com/
>> >>>> Twitter: http://twitter.com/davsclaus
>> >>>>
>> >>>
>> >>>
>> >>
>> >
>> >
>> >
>> > --
>> > Claus Ibsen
>> > Apache Camel Committer
>> >
>> > Open Source Integration: http://fusesource.com
>> > Blog: http://davsclaus.blogspot.com/
>> > Twitter: http://twitter.com/davsclaus
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Claus Ibsen-2
On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<[hidden email]> wrote:
> In this case, you should not use transactions for the DB at all, but
> if any error occurs while saving the data, an exception should be
> thrown and should rollback the transaction for the JMS layer.
Yeah that would be perfect unless he does some work afterwards the DB
and that throws an Exception.
Then the DB layer have already committed.

So trying to avoid doing work after the DB layer would help.


Is this not possible?
But he is doing JPA/Hibernte stuff so he could grab the "session" and
invoke a rollback manually in case errors happen afterwards.




>
> On Fri, Jul 3, 2009 at 10:48, Charles Moulliard<[hidden email]> wrote:
>> Claus,
>>
>> I don't want at all to use XA transaction. Correct me if I'm wrong but the
>> example of the documentation (Camel 2.0 - JMS Sample - part Spring XML) does
>> not use at all a XA driver and the message will not be removed from the
>> queue if a rollback occurs in the bean MyProcessor ?
>>
>> My concern is to avoid to lost messages from a file, queues if something
>> happen in one of the services called where by example we have to save data
>> in a DB or generate a report for a client. If such errors occur, then we
>> have to investigate why can't save data in DB (maybe related to a connection
>> issue, DB shutdown, ...) or generates files (maybe due to disk full, access
>> right, ....). Sometimes, this is related to conditions out of the control of
>> our application but sometimes no, then we have to correct the error and
>> install a new version of the code. After the restart of the application and
>> recovery of messages (persisted in the case of activemq), messages will be
>> reprocessed.
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]> wrote:
>>
>>> And reconsider if you need XA at all. Its slow and hard to get setup.
>>>
>>> Try to let the DB be the last stuff you do and afterwards send the
>>> message to another queue for further processing in a 2nd route.
>>> If that is possible in your use-case.
>>>
>>>
>>> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]> wrote:
>>> > Hi
>>> >
>>> > Get it working outside OSGi, eg in a small unit test thats easy to run
>>> > and test from within your IDE.
>>> > Google for JMS + hibernate + TX + XA to find some samples that work.
>>> >
>>> > And since you use JMS + DB in the same TX you need to use XA db driver.
>>> >
>>> > It can be a painful to get setup
>>> >
>>> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
>>> >
>>> > And you need an XA TX manager such as JOTM
>>> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
>>> >
>>> > In j2ee land there was a JTA with the container that could do it. But
>>> > in your OSGi container I do not know if it provides one out of the
>>> > box.
>>> >
>>> >
>>> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<[hidden email]>
>>> wrote:
>>> >> I'm still fighting against Spring config or Camel because Rollback does
>>> not
>>> >> occur. I have been able to configure Hibernate to use the same
>>> >> TransactionManager as the one used by JMS
>>> >>
>>> >> Here is the different part of the config. I don't know where the issue
>>> could
>>> >> be !
>>> >>
>>> >> 1) ActiveMQ
>>> >>
>>> >> ...
>>> >>
>>> >>    <bean id="activemqConnectionFactory"
>>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>>> >>        <property name="brokerURL" value="tcp://localhost:61616" />
>>> >>    </bean>
>>> >>
>>> >>    <bean id="pooledConnectionFactory"
>>> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
>>> >>        <property name="maxConnections" value="8" />
>>> >>        <property name="maximumActive" value="500" />
>>> >>        <property name="transactionManager" ref="transactionManager" />
>>> >>        <property name="connectionFactory"
>>> ref="activemqConnectionFactory"
>>> >> />
>>> >>        <property name="resourceName" value="activemq.default" />
>>> >>    </bean>
>>> >>
>>> >>    <bean id="resourceManager"
>>> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
>>> >> init-method="recoverResource">
>>> >>          <property name="transactionManager" ref="transactionManager" />
>>> >>          <property name="connectionFactory"
>>> ref="activemqConnectionFactory"
>>> >> />
>>> >>          <property name="resourceName" value="activemq.default" />
>>> >>    </bean>
>>> >>
>>> >>    <osgi:reference id="transactionManager"
>>> >> interface="javax.transaction.TransactionManager" /> // This OSGI service
>>> is
>>> >> published by Geronimo Transaction bundle
>>> >>
>>> >>    <osgi:service ref="pooledConnectionFactory">
>>> >>        <osgi:interfaces>
>>> >>            <value>javax.jms.ConnectionFactory</value>
>>> >>        </osgi:interfaces>
>>> >>        <osgi:service-properties>
>>> >>            <entry key="name" value="default"/>
>>> >>        </osgi:service-properties>
>>> >>    </osgi:service>
>>> >>
>>> >> 2) Camel ActiveMQComponent
>>> >>
>>> >>    <bean id="active-mq"
>>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>> >>        <property name="transacted" value="true"/>
>>> >>        <property name="connectionFactory">
>>> >>            <osgi:reference interface="javax.jms.ConnectionFactory"/> //
>>> >> OSGI service is published by ActiveMQ service
>>> >>        </property>
>>> >>        <property name="transactionManager">
>>> >>            <osgi:reference
>>> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>        </property>
>>> >>    </bean>
>>> >>
>>> >> 2) Hibernate - DAO
>>> >>
>>> >>    <bean id="sessionFactory"
>>> >> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>>> >>
>>> >>        <property name="mappingLocations">
>>> >>            <list>
>>> >>
>>> >>
>>> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
>>> >>            </list>
>>> >>        </property>
>>> >>
>>> >>        <property name="hibernateProperties">
>>> >>            <props>
>>> >>                <prop
>>> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>>> >>                <prop key="hibernate.show_sql">true</prop>
>>> >>                <prop key="hibernate.format_sql">true</prop>
>>> >>                <prop
>>> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>>> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
>>> >>                <prop
>>> >>
>>> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
>>> >>                <prop
>>> >>
>>> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
>>> >>            </props>
>>> >>        </property>
>>> >>        <property name="dataSource">
>>> >>            <ref bean="dataSource" />
>>> >>        </property>
>>> >>
>>> >> Remark : To avoid the JNDI lookup issue, we use springTransactionFactory
>>> as
>>> >> the TransactionFactory for Hibernate (
>>> >> http://forum.springsource.org/showthread.php?p=215720)
>>> >>
>>> >> 3) Service layer
>>> >>
>>> >> Here is the definition of the service used from Camel route :
>>> >>
>>> >>    <bean id="notificationServiceTarget"
>>> >> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
>>> >>            <property name="notificationDAO">
>>> >>            <osgi:reference
>>> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
>>> >>        </property>
>>> >>
>>> >>    </bean>
>>> >>
>>> >>   <!-- Abstract service using the Geronimo Transaction Manager -->
>>> >>    <bean id="abstractService" abstract="true"
>>> >>
>>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>>> >>         <property name="transactionManager">
>>> >>            <osgi:reference
>>> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>        </property>
>>> >>    </bean>
>>> >>
>>> >>    <bean id="notificationService"
>>> >>          parent="abstractService"
>>> >>
>>> >>
>>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>>> >>
>>> >>        <property name="target">
>>> >>            <ref bean="notificationServiceTarget" />
>>> >>        </property>
>>> >>
>>> >>        <property name="transactionAttributes">
>>> >>            <props>
>>> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
>>> >>            </props>
>>> >>        </property>
>>> >>    </bean>
>>> >>
>>> >> 4) Route
>>> >>
>>> >>    <bean id="myPolicy"
>>> class="org.apache.camel.processor.RedeliveryPolicy">
>>> >>        <property name="maximumRedeliveries" value="1"/>
>>> >>    </bean>
>>> >>
>>> >>    <bean id="txErrorHandler"
>>> >> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>>> >>        <property name="springTransactionPolicy"
>>> >> ref="PROPAGATION_REQUIRED"/>
>>> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
>>> >>    </bean>
>>> >>
>>> >>    <bean id="PROPAGATION_REQUIRED"
>>> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>> >>        <property name="transactionManager">
>>> >>            <osgi:reference
>>> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>        </property>
>>> >>    </bean>
>>> >>
>>> >>        <camel:route errorHandlerRef="txErrorHandler">
>>> >>            <camel:from ref="queueQuickFixInEndpoint" />
>>> >>            <camel:convertBodyTo type="quickfix.Message" />
>>> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>>> >>            <camel:bean ref="serviceHelper" method="createNotification"
>>> />
>>> >>            <camel:bean ref="serviceHelper" method="generateError" />
>>> >>            <camel:to ref="directNotificationEndpoint" />
>>> >>        </camel:route>
>>> >>
>>> >> Any ideas are welcome
>>> >>
>>> >> Regards,
>>> >>
>>> >> Charles Moulliard
>>> >> Senior Enterprise Architect
>>> >> Apache Camel Committer
>>> >>
>>> >> *****************************
>>> >> blog : http://cmoulliard.blogspot.com
>>> >>
>>> >>
>>> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <[hidden email]
>>> >wrote:
>>> >>
>>> >>> OK. I will try to create my own Hibernate JTATransaction manager as the
>>> >>> existing try to perform a JNDI lookup to find the transaction manager
>>> on
>>> >>> OSGI platform (inheritage from J2EE world)
>>> >>>
>>> >>>
>>> >>>
>>> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>>> >>>
>>> >>>
>>> >>> Charles Moulliard
>>> >>> Senior Enterprise Architect
>>> >>> Apache Camel Committer
>>> >>>
>>> >>> *****************************
>>> >>> blog : http://cmoulliard.blogspot.com
>>> >>>
>>> >>>
>>> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]>
>>> wrote:
>>> >>>
>>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>>> [hidden email]>
>>> >>>> wrote:
>>> >>>> > queueQuickFixInEndpoint is a JMS queue.
>>> >>>> >
>>> >>>> > I will add the ref to the transacted and retest
>>> >>>> >
>>> >>>> > Question : I suppose that rollback will not occur if by example JMS
>>> and
>>> >>>> DB
>>> >>>> > (=Hibernate) does not use the same TransactionManager and don't use
>>> this
>>> >>>> > spring class together :
>>> >>>> > org.springframework.transaction.PlatformTransactionManager
>>> >>>> Yes they must be configured to use the same TX manager.
>>> >>>>
>>> >>>>
>>> >>>> >
>>> >>>> > Regards,
>>> >>>> >
>>> >>>> > Charles Moulliard
>>> >>>> > Senior Enterprise Architect
>>> >>>> > Apache Camel Committer
>>> >>>> >
>>> >>>> > *****************************
>>> >>>> > blog : http://cmoulliard.blogspot.com
>>> >>>> >
>>> >>>> >
>>> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <[hidden email]>
>>> >>>> wrote:
>>> >>>> >
>>> >>>> >> Transacted also have a ref attribute
>>> >>>> >>
>>> >>>> >> <transacted ref="required"/>
>>> >>>> >>
>>> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
>>> >>>> >> You need to use a TX manager that can do both JMS and DB.
>>> >>>> >>
>>> >>>> >>
>>> >>>> >>
>>> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
>>> [hidden email]
>>> >>>> >
>>> >>>> >> wrote:
>>> >>>> >> > I have been able to solve my problem by adding the following bean
>>> >>>> >> definition
>>> >>>> >> > :
>>> >>>> >> >
>>> >>>> >> >    <bean id="required"
>>> >>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>> >>>> >> >        <property name="transactionManager">
>>> >>>> >> >            <osgi:reference
>>> >>>> >> >
>>> >>>>
>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>>> >> >        </property>
>>> >>>> >> >    </bean>
>>> >>>> >> >
>>> >>>> >> > and in the route
>>> >>>> >> >
>>> >>>> >> >        <camel:route>
>>> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>>> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>>> >>>> >> >            <camel:transacted/>
>>> >>>> >> >            <camel:policy ref="required" />
>>> >>>> >> >            <camel:bean ref="serviceHelper"
>>> >>>> method="createNotification" />
>>> >>>> >> >            <camel:bean ref="serviceHelper" method="generateError"
>>> />
>>> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
>>> >>>> >> >        </camel:route>
>>> >>>> >> >
>>> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
>>> records
>>> >>>> have
>>> >>>> >> been
>>> >>>> >> > created by the method createNotification when error has been
>>> raised
>>> >>>> by
>>> >>>> >> the
>>> >>>> >> > method generateError.
>>> >>>> >> >
>>> >>>> >> > What is missing ?
>>> >>>> >> >
>>> >>>> >> > Charles Moulliard
>>> >>>> >> > Senior Enterprise Architect
>>> >>>> >> > Apache Camel Committer
>>> >>>> >> >
>>> >>>> >> > *****************************
>>> >>>> >> > blog : http://cmoulliard.blogspot.com
>>> >>>> >> >
>>> >>>> >> >
>>> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>>> >>>> [hidden email]
>>> >>>> >> >wrote:
>>> >>>> >> >
>>> >>>> >> >> When I compare the example :
>>> JMSTransactionalClientRollbackTest.xml
>>> >>>> >> >>
>>> >>>> >> >>     <!-- START SNIPPET: e1 -->
>>> >>>> >> >>     <!-- setup JMS connection factory -->
>>> >>>> >> >>     <bean id="jmsConnectionFactory"
>>> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>>> >>>> >> >>         <property name="brokerURL"
>>> >>>> >> >>
>>> >>>>
>>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>>> >>>> >> >>     </bean>
>>> >>>> >> >>
>>> >>>> >> >>     <!-- setup spring jms TX manager -->
>>> >>>> >> >>     <bean id="jmsTransactionManager"
>>> >>>> >> >>
>>> class="org.springframework.jms.connection.JmsTransactionManager">
>>> >>>> >> >>         <property name="connectionFactory"
>>> >>>> ref="jmsConnectionFactory"/>
>>> >>>> >> >>     </bean>
>>> >>>> >> >>
>>> >>>> >> >>     <!-- define our activemq component -->
>>> >>>> >> >>     <bean id="activemq"
>>> >>>> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>> >>>> >> >>         <property name="connectionFactory"
>>> >>>> ref="jmsConnectionFactory"/>
>>> >>>> >> >>         <!-- define the jms consumer/producer as transacted -->
>>> >>>> >> >>         <property name="transacted" value="true"/>
>>> >>>> >> >>         <!-- setup the transaction manager to use -->
>>> >>>> >> >>         <!-- if not provided then Camel will automatic use a
>>> >>>> >> >> JmsTransactionManager, however if you
>>> >>>> >> >>              for instance use a JTA transaction manager then you
>>> >>>> must
>>> >>>> >> >> configure it -->
>>> >>>> >> >>         <property name="transactionManager"
>>> >>>> >> ref="jmsTransactionManager"/>
>>> >>>> >> >>     </bean>
>>> >>>> >> >>     <!-- END SNIPPET: e1 -->
>>> >>>> >> >>
>>> >>>> >> >>     <!-- START SNIPPET: e2 -->
>>> >>>> >> >>     <camelContext xmlns="http://camel.apache.org/schema/spring
>>> ">
>>> >>>> >> >>         <route>
>>> >>>> >> >>             <!-- 1: from the jms queue -->
>>> >>>> >> >>             <from uri="activemq:queue:okay"/>
>>> >>>> >> >>             <!-- 2: mark this route as transacted -->
>>> >>>> >> >>             <transacted/>
>>> >>>> >> >>             <!-- 3: call our business logic that is myProcessor
>>> -->
>>> >>>> >> >>             <process ref="myProcessor"/>
>>> >>>> >> >>             <!-- 4: if success then send it to the mock -->
>>> >>>> >> >>             <to uri="mock:result"/>
>>> >>>> >> >>         </route>
>>> >>>> >> >>     </camelContext>
>>> >>>> >> >>
>>> >>>> >> >> with mine.
>>> >>>> >> >>
>>> >>>> >> >> What is different concerns the TransactionManager used.
>>> >>>> >> >>
>>> >>>> >> >> In the example, this is the Spring one:
>>> >>>> >> >>
>>> >>>> >> >>     <!-- setup spring jms TX manager -->
>>> >>>> >> >>     <bean id="jmsTransactionManager"
>>> >>>> >> >>
>>> class="org.springframework.jms.connection.JmsTransactionManager">
>>> >>>> >> >>         <property name="connectionFactory"
>>> >>>> ref="jmsConnectionFactory"/>
>>> >>>> >> >>     </bean>
>>> >>>> >> >>
>>> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
>>> Transaction
>>> >>>> >> Manager
>>> >>>> >> >> bundle (which in fact uses spring Transaction manager :
>>> >>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>>> >>>> >> >>
>>> >>>> >> >> I suppose that in the example, the policy is defined by default
>>> by
>>> >>>> >> spring
>>> >>>> >> >> when instantiating the class :
>>> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
>>> >>>> >> >>
>>> >>>> >> >> Is it possible to do the same using a JtaTransaction manager ?
>>> >>>> >> >>
>>> >>>> >> >> Regards,
>>> >>>> >> >>
>>> >>>> >> >> Charles Moulliard
>>> >>>> >> >> Senior Enterprise Architect
>>> >>>> >> >> Apache Camel Committer
>>> >>>> >> >>
>>> >>>> >> >> *****************************
>>> >>>> >> >> blog : http://cmoulliard.blogspot.com
>>> >>>> >> >>
>>> >>>> >> >>
>>> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
>>> [hidden email]>
>>> >>>> >> wrote:
>>> >>>> >> >>
>>> >>>> >> >>> Hi
>>> >>>> >> >>>
>>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
>>> >>>> >> >>>
>>> >>>> >> >>>
>>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>>> >>>> [hidden email]
>>> >>>> >> >
>>> >>>> >> >>> wrote:
>>> >>>> >> >>> > Camel generates the following error with my route :
>>> >>>> >> >>> >
>>> >>>> >> >>> > Route
>>> >>>> >> >>> >
>>> >>>> >> >>> >        <camel:route>
>>> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>>> >>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message" />
>>> >>>> >> >>> >            <camel:transacted/>
>>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>>> >>>> >> method="createNotification"
>>> >>>> >> >>> />
>>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>>> method="generateError"
>>> >>>> />
>>> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>>> >>>> >> >>> >        </camel:route>
>>> >>>> >> >>> >
>>> >>>> >> >>> > It seems that policy must be defined but in the example here
>>> it
>>> >>>> is
>>> >>>> >> not
>>> >>>> >> >>> > mentioned :
>>> http://camel.apache.org/transactional-client.html
>>> >>>> >> >>> >
>>> >>>> >> >>> > Error :
>>> >>>> >> >>> >
>>> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
>>> ContextLoaderListener
>>> >>>> >> >>>    |
>>> >>>> >> >>> > BundleApplicationContextListener   50 | Application context
>>> >>>> refresh
>>> >>>> >> >>> failed
>>> >>>> >> >>> >
>>> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>>> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>>> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
>>> >>>> >> >>> java.lang.IllegalArgumentException:
>>> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>>> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>>> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy must be
>>> >>>> >> specified
>>> >>>> >> >>> on:
>>> >>>> >> >>> > Transacted[ref: null]
>>> >>>> >> >>> >    at
>>> >>>> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>>> >>>> >> >>> >    at
>>> >>>> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>>> >>>> >> >>> >    at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>>> >>>> >> >>> > Charles Moulliard
>>> >>>> >> >>> > Senior Enterprise Architect
>>> >>>> >> >>> > Apache Camel Committer
>>> >>>> >> >>> >
>>> >>>> >> >>> > *****************************
>>> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >> >>>
>>> >>>> >> >>>
>>> >>>> >> >>> --
>>> >>>> >> >>> Claus Ibsen
>>> >>>> >> >>> Apache Camel Committer
>>> >>>> >> >>>
>>> >>>> >> >>> Open Source Integration: http://fusesource.com
>>> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
>>> >>>> >> >>> Twitter: http://twitter.com/davsclaus
>>> >>>> >> >>>
>>> >>>> >> >>
>>> >>>> >> >>
>>> >>>> >> >
>>> >>>> >>
>>> >>>> >>
>>> >>>> >>
>>> >>>> >> --
>>> >>>> >> Claus Ibsen
>>> >>>> >> Apache Camel Committer
>>> >>>> >>
>>> >>>> >> Open Source Integration: http://fusesource.com
>>> >>>> >> Blog: http://davsclaus.blogspot.com/
>>> >>>> >> Twitter: http://twitter.com/davsclaus
>>> >>>> >>
>>> >>>> >
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>> --
>>> >>>> Claus Ibsen
>>> >>>> Apache Camel Committer
>>> >>>>
>>> >>>> Open Source Integration: http://fusesource.com
>>> >>>> Blog: http://davsclaus.blogspot.com/
>>> >>>> Twitter: http://twitter.com/davsclaus
>>> >>>>
>>> >>>
>>> >>>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Claus Ibsen
>>> > Apache Camel Committer
>>> >
>>> > Open Source Integration: http://fusesource.com
>>> > Blog: http://davsclaus.blogspot.com/
>>> > Twitter: http://twitter.com/davsclaus
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
I have created a small route without JMS stuff.

Here is the route :

        <camel:route>
            <camel:from ref="fileClientEndpoint" />

            <camel:setHeader headerName="origin">
                <camel:constant>file</camel:constant>
            </camel:setHeader>
            <camel:setHeader headerName="messageType">
                <camel:constant>OINP</camel:constant>
            </camel:setHeader>
            <camel:convertBodyTo type="java.lang.String"/>
            <camel:to ref="directRequestEndpoint" />
        </camel:route>

        <camel:route>
            <camel:from ref="directRequestEndpoint" />
            <camel:transacted ref="PROPAGATION_REQUIRED"/>
            <!-- Call the requestService to save the request -->
            <camel:bean ref="serviceHelper" method="createRequest"/>
            <camel:bean ref="serviceHelper" method="generateError" />
            <camel:to uri="direct:testTx"/>
        </camel:route>

Unfortunately when a throw error is generated in bean called "generateError"

    public void generateError() {
            throw new IllegalArgumentException("Generate error to test
rollback");
    }

records are committed in the DB and not rollbacked


I see that when the error is throw the message is redelivered a second time
as this parameter has been defined in the ActiveMq

    <bean id="x3sPolicy" class="org.apache.activemq.RedeliveryPolicy">
*        <property name="maximumRedeliveries" value="1"/>*
    </bean>

    <bean id="activemqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616" />
        <property name="redeliveryPolicy" ref="x3sPolicy"/>
    </bean>

Question :  Why policy defined in the ActiveMq is taken into account here ?
Why the rollback does not occur ?

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jul 3, 2009 at 12:28 PM, Claus Ibsen <[hidden email]> wrote:

> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<[hidden email]> wrote:
> > In this case, you should not use transactions for the DB at all, but
> > if any error occurs while saving the data, an exception should be
> > thrown and should rollback the transaction for the JMS layer.
> Yeah that would be perfect unless he does some work afterwards the DB
> and that throws an Exception.
> Then the DB layer have already committed.
>
> So trying to avoid doing work after the DB layer would help.
>
>
> Is this not possible?
> But he is doing JPA/Hibernte stuff so he could grab the "session" and
> invoke a rollback manually in case errors happen afterwards.
>
>
>
>
> >
> > On Fri, Jul 3, 2009 at 10:48, Charles Moulliard<[hidden email]>
> wrote:
> >> Claus,
> >>
> >> I don't want at all to use XA transaction. Correct me if I'm wrong but
> the
> >> example of the documentation (Camel 2.0 - JMS Sample - part Spring XML)
> does
> >> not use at all a XA driver and the message will not be removed from the
> >> queue if a rollback occurs in the bean MyProcessor ?
> >>
> >> My concern is to avoid to lost messages from a file, queues if something
> >> happen in one of the services called where by example we have to save
> data
> >> in a DB or generate a report for a client. If such errors occur, then we
> >> have to investigate why can't save data in DB (maybe related to a
> connection
> >> issue, DB shutdown, ...) or generates files (maybe due to disk full,
> access
> >> right, ....). Sometimes, this is related to conditions out of the
> control of
> >> our application but sometimes no, then we have to correct the error and
> >> install a new version of the code. After the restart of the application
> and
> >> recovery of messages (persisted in the case of activemq), messages will
> be
> >> reprocessed.
> >>
> >> Regards,
> >>
> >> Charles Moulliard
> >> Senior Enterprise Architect
> >> Apache Camel Committer
> >>
> >> *****************************
> >> blog : http://cmoulliard.blogspot.com
> >>
> >>
> >> On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]>
> wrote:
> >>
> >>> And reconsider if you need XA at all. Its slow and hard to get setup.
> >>>
> >>> Try to let the DB be the last stuff you do and afterwards send the
> >>> message to another queue for further processing in a 2nd route.
> >>> If that is possible in your use-case.
> >>>
> >>>
> >>> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]>
> wrote:
> >>> > Hi
> >>> >
> >>> > Get it working outside OSGi, eg in a small unit test thats easy to
> run
> >>> > and test from within your IDE.
> >>> > Google for JMS + hibernate + TX + XA to find some samples that work.
> >>> >
> >>> > And since you use JMS + DB in the same TX you need to use XA db
> driver.
> >>> >
> >>> > It can be a painful to get setup
> >>> >
> >>>
> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
> >>> >
> >>> > And you need an XA TX manager such as JOTM
> >>> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
> >>> >
> >>> > In j2ee land there was a JTA with the container that could do it. But
> >>> > in your OSGi container I do not know if it provides one out of the
> >>> > box.
> >>> >
> >>> >
> >>> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<
> [hidden email]>
> >>> wrote:
> >>> >> I'm still fighting against Spring config or Camel because Rollback
> does
> >>> not
> >>> >> occur. I have been able to configure Hibernate to use the same
> >>> >> TransactionManager as the one used by JMS
> >>> >>
> >>> >> Here is the different part of the config. I don't know where the
> issue
> >>> could
> >>> >> be !
> >>> >>
> >>> >> 1) ActiveMQ
> >>> >>
> >>> >> ...
> >>> >>
> >>> >>    <bean id="activemqConnectionFactory"
> >>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >>> >>        <property name="brokerURL" value="tcp://localhost:61616" />
> >>> >>    </bean>
> >>> >>
> >>> >>    <bean id="pooledConnectionFactory"
> >>> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
> >>> >>        <property name="maxConnections" value="8" />
> >>> >>        <property name="maximumActive" value="500" />
> >>> >>        <property name="transactionManager" ref="transactionManager"
> />
> >>> >>        <property name="connectionFactory"
> >>> ref="activemqConnectionFactory"
> >>> >> />
> >>> >>        <property name="resourceName" value="activemq.default" />
> >>> >>    </bean>
> >>> >>
> >>> >>    <bean id="resourceManager"
> >>> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
> >>> >> init-method="recoverResource">
> >>> >>          <property name="transactionManager"
> ref="transactionManager" />
> >>> >>          <property name="connectionFactory"
> >>> ref="activemqConnectionFactory"
> >>> >> />
> >>> >>          <property name="resourceName" value="activemq.default" />
> >>> >>    </bean>
> >>> >>
> >>> >>    <osgi:reference id="transactionManager"
> >>> >> interface="javax.transaction.TransactionManager" /> // This OSGI
> service
> >>> is
> >>> >> published by Geronimo Transaction bundle
> >>> >>
> >>> >>    <osgi:service ref="pooledConnectionFactory">
> >>> >>        <osgi:interfaces>
> >>> >>            <value>javax.jms.ConnectionFactory</value>
> >>> >>        </osgi:interfaces>
> >>> >>        <osgi:service-properties>
> >>> >>            <entry key="name" value="default"/>
> >>> >>        </osgi:service-properties>
> >>> >>    </osgi:service>
> >>> >>
> >>> >> 2) Camel ActiveMQComponent
> >>> >>
> >>> >>    <bean id="active-mq"
> >>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >>> >>        <property name="transacted" value="true"/>
> >>> >>        <property name="connectionFactory">
> >>> >>            <osgi:reference interface="javax.jms.ConnectionFactory"/>
> //
> >>> >> OSGI service is published by ActiveMQ service
> >>> >>        </property>
> >>> >>        <property name="transactionManager">
> >>> >>            <osgi:reference
> >>> >>
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>> >>        </property>
> >>> >>    </bean>
> >>> >>
> >>> >> 2) Hibernate - DAO
> >>> >>
> >>> >>    <bean id="sessionFactory"
> >>> >> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> >>> >>
> >>> >>        <property name="mappingLocations">
> >>> >>            <list>
> >>> >>
> >>> >>
> >>>
> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
> >>> >>            </list>
> >>> >>        </property>
> >>> >>
> >>> >>        <property name="hibernateProperties">
> >>> >>            <props>
> >>> >>                <prop
> >>> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
> >>> >>                <prop key="hibernate.show_sql">true</prop>
> >>> >>                <prop key="hibernate.format_sql">true</prop>
> >>> >>                <prop
> >>> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
> >>> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
> >>> >>                <prop
> >>> >>
> >>>
> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
> >>> >>                <prop
> >>> >>
> >>>
> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
> >>> >>            </props>
> >>> >>        </property>
> >>> >>        <property name="dataSource">
> >>> >>            <ref bean="dataSource" />
> >>> >>        </property>
> >>> >>
> >>> >> Remark : To avoid the JNDI lookup issue, we use
> springTransactionFactory
> >>> as
> >>> >> the TransactionFactory for Hibernate (
> >>> >> http://forum.springsource.org/showthread.php?p=215720)
> >>> >>
> >>> >> 3) Service layer
> >>> >>
> >>> >> Here is the definition of the service used from Camel route :
> >>> >>
> >>> >>    <bean id="notificationServiceTarget"
> >>> >>
> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
> >>> >>            <property name="notificationDAO">
> >>> >>            <osgi:reference
> >>> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
> >>> >>        </property>
> >>> >>
> >>> >>    </bean>
> >>> >>
> >>> >>   <!-- Abstract service using the Geronimo Transaction Manager -->
> >>> >>    <bean id="abstractService" abstract="true"
> >>> >>
> >>>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
> >>> >>         <property name="transactionManager">
> >>> >>            <osgi:reference
> >>> >>
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>> >>        </property>
> >>> >>    </bean>
> >>> >>
> >>> >>    <bean id="notificationService"
> >>> >>          parent="abstractService"
> >>> >>
> >>> >>
> >>>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
> >>> >>
> >>> >>        <property name="target">
> >>> >>            <ref bean="notificationServiceTarget" />
> >>> >>        </property>
> >>> >>
> >>> >>        <property name="transactionAttributes">
> >>> >>            <props>
> >>> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
> >>> >>            </props>
> >>> >>        </property>
> >>> >>    </bean>
> >>> >>
> >>> >> 4) Route
> >>> >>
> >>> >>    <bean id="myPolicy"
> >>> class="org.apache.camel.processor.RedeliveryPolicy">
> >>> >>        <property name="maximumRedeliveries" value="1"/>
> >>> >>    </bean>
> >>> >>
> >>> >>    <bean id="txErrorHandler"
> >>> >> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
> >>> >>        <property name="springTransactionPolicy"
> >>> >> ref="PROPAGATION_REQUIRED"/>
> >>> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
> >>> >>    </bean>
> >>> >>
> >>> >>    <bean id="PROPAGATION_REQUIRED"
> >>> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >>> >>        <property name="transactionManager">
> >>> >>            <osgi:reference
> >>> >>
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>> >>        </property>
> >>> >>    </bean>
> >>> >>
> >>> >>        <camel:route errorHandlerRef="txErrorHandler">
> >>> >>            <camel:from ref="queueQuickFixInEndpoint" />
> >>> >>            <camel:convertBodyTo type="quickfix.Message" />
> >>> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
> >>> >>            <camel:bean ref="serviceHelper"
> method="createNotification"
> >>> />
> >>> >>            <camel:bean ref="serviceHelper" method="generateError" />
> >>> >>            <camel:to ref="directNotificationEndpoint" />
> >>> >>        </camel:route>
> >>> >>
> >>> >> Any ideas are welcome
> >>> >>
> >>> >> Regards,
> >>> >>
> >>> >> Charles Moulliard
> >>> >> Senior Enterprise Architect
> >>> >> Apache Camel Committer
> >>> >>
> >>> >> *****************************
> >>> >> blog : http://cmoulliard.blogspot.com
> >>> >>
> >>> >>
> >>> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <
> [hidden email]
> >>> >wrote:
> >>> >>
> >>> >>> OK. I will try to create my own Hibernate JTATransaction manager as
> the
> >>> >>> existing try to perform a JNDI lookup to find the transaction
> manager
> >>> on
> >>> >>> OSGI platform (inheritage from J2EE world)
> >>> >>>
> >>> >>>
> >>> >>>
> >>>
> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
> >>> >>>
> >>> >>>
> >>> >>> Charles Moulliard
> >>> >>> Senior Enterprise Architect
> >>> >>> Apache Camel Committer
> >>> >>>
> >>> >>> *****************************
> >>> >>> blog : http://cmoulliard.blogspot.com
> >>> >>>
> >>> >>>
> >>> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]
> >
> >>> wrote:
> >>> >>>
> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> >>> [hidden email]>
> >>> >>>> wrote:
> >>> >>>> > queueQuickFixInEndpoint is a JMS queue.
> >>> >>>> >
> >>> >>>> > I will add the ref to the transacted and retest
> >>> >>>> >
> >>> >>>> > Question : I suppose that rollback will not occur if by example
> JMS
> >>> and
> >>> >>>> DB
> >>> >>>> > (=Hibernate) does not use the same TransactionManager and don't
> use
> >>> this
> >>> >>>> > spring class together :
> >>> >>>> > org.springframework.transaction.PlatformTransactionManager
> >>> >>>> Yes they must be configured to use the same TX manager.
> >>> >>>>
> >>> >>>>
> >>> >>>> >
> >>> >>>> > Regards,
> >>> >>>> >
> >>> >>>> > Charles Moulliard
> >>> >>>> > Senior Enterprise Architect
> >>> >>>> > Apache Camel Committer
> >>> >>>> >
> >>> >>>> > *****************************
> >>> >>>> > blog : http://cmoulliard.blogspot.com
> >>> >>>> >
> >>> >>>> >
> >>> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <
> [hidden email]>
> >>> >>>> wrote:
> >>> >>>> >
> >>> >>>> >> Transacted also have a ref attribute
> >>> >>>> >>
> >>> >>>> >> <transacted ref="required"/>
> >>> >>>> >>
> >>> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
> >>> >>>> >> You need to use a TX manager that can do both JMS and DB.
> >>> >>>> >>
> >>> >>>> >>
> >>> >>>> >>
> >>> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
> >>> [hidden email]
> >>> >>>> >
> >>> >>>> >> wrote:
> >>> >>>> >> > I have been able to solve my problem by adding the following
> bean
> >>> >>>> >> definition
> >>> >>>> >> > :
> >>> >>>> >> >
> >>> >>>> >> >    <bean id="required"
> >>> >>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >>> >>>> >> >        <property name="transactionManager">
> >>> >>>> >> >            <osgi:reference
> >>> >>>> >> >
> >>> >>>>
> >>>
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >>> >>>> >> >        </property>
> >>> >>>> >> >    </bean>
> >>> >>>> >> >
> >>> >>>> >> > and in the route
> >>> >>>> >> >
> >>> >>>> >> >        <camel:route>
> >>> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
> >>> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
> >>> >>>> >> >            <camel:transacted/>
> >>> >>>> >> >            <camel:policy ref="required" />
> >>> >>>> >> >            <camel:bean ref="serviceHelper"
> >>> >>>> method="createNotification" />
> >>> >>>> >> >            <camel:bean ref="serviceHelper"
> method="generateError"
> >>> />
> >>> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
> >>> >>>> >> >        </camel:route>
> >>> >>>> >> >
> >>> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
> >>> records
> >>> >>>> have
> >>> >>>> >> been
> >>> >>>> >> > created by the method createNotification when error has been
> >>> raised
> >>> >>>> by
> >>> >>>> >> the
> >>> >>>> >> > method generateError.
> >>> >>>> >> >
> >>> >>>> >> > What is missing ?
> >>> >>>> >> >
> >>> >>>> >> > Charles Moulliard
> >>> >>>> >> > Senior Enterprise Architect
> >>> >>>> >> > Apache Camel Committer
> >>> >>>> >> >
> >>> >>>> >> > *****************************
> >>> >>>> >> > blog : http://cmoulliard.blogspot.com
> >>> >>>> >> >
> >>> >>>> >> >
> >>> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
> >>> >>>> [hidden email]
> >>> >>>> >> >wrote:
> >>> >>>> >> >
> >>> >>>> >> >> When I compare the example :
> >>> JMSTransactionalClientRollbackTest.xml
> >>> >>>> >> >>
> >>> >>>> >> >>     <!-- START SNIPPET: e1 -->
> >>> >>>> >> >>     <!-- setup JMS connection factory -->
> >>> >>>> >> >>     <bean id="jmsConnectionFactory"
> >>> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >>> >>>> >> >>         <property name="brokerURL"
> >>> >>>> >> >>
> >>> >>>>
> >>>
> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
> >>> >>>> >> >>     </bean>
> >>> >>>> >> >>
> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
> >>> >>>> >> >>     <bean id="jmsTransactionManager"
> >>> >>>> >> >>
> >>> class="org.springframework.jms.connection.JmsTransactionManager">
> >>> >>>> >> >>         <property name="connectionFactory"
> >>> >>>> ref="jmsConnectionFactory"/>
> >>> >>>> >> >>     </bean>
> >>> >>>> >> >>
> >>> >>>> >> >>     <!-- define our activemq component -->
> >>> >>>> >> >>     <bean id="activemq"
> >>> >>>> >> >>
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >>> >>>> >> >>         <property name="connectionFactory"
> >>> >>>> ref="jmsConnectionFactory"/>
> >>> >>>> >> >>         <!-- define the jms consumer/producer as transacted
> -->
> >>> >>>> >> >>         <property name="transacted" value="true"/>
> >>> >>>> >> >>         <!-- setup the transaction manager to use -->
> >>> >>>> >> >>         <!-- if not provided then Camel will automatic use a
> >>> >>>> >> >> JmsTransactionManager, however if you
> >>> >>>> >> >>              for instance use a JTA transaction manager then
> you
> >>> >>>> must
> >>> >>>> >> >> configure it -->
> >>> >>>> >> >>         <property name="transactionManager"
> >>> >>>> >> ref="jmsTransactionManager"/>
> >>> >>>> >> >>     </bean>
> >>> >>>> >> >>     <!-- END SNIPPET: e1 -->
> >>> >>>> >> >>
> >>> >>>> >> >>     <!-- START SNIPPET: e2 -->
> >>> >>>> >> >>     <camelContext xmlns="
> http://camel.apache.org/schema/spring
> >>> ">
> >>> >>>> >> >>         <route>
> >>> >>>> >> >>             <!-- 1: from the jms queue -->
> >>> >>>> >> >>             <from uri="activemq:queue:okay"/>
> >>> >>>> >> >>             <!-- 2: mark this route as transacted -->
> >>> >>>> >> >>             <transacted/>
> >>> >>>> >> >>             <!-- 3: call our business logic that is
> myProcessor
> >>> -->
> >>> >>>> >> >>             <process ref="myProcessor"/>
> >>> >>>> >> >>             <!-- 4: if success then send it to the mock -->
> >>> >>>> >> >>             <to uri="mock:result"/>
> >>> >>>> >> >>         </route>
> >>> >>>> >> >>     </camelContext>
> >>> >>>> >> >>
> >>> >>>> >> >> with mine.
> >>> >>>> >> >>
> >>> >>>> >> >> What is different concerns the TransactionManager used.
> >>> >>>> >> >>
> >>> >>>> >> >> In the example, this is the Spring one:
> >>> >>>> >> >>
> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
> >>> >>>> >> >>     <bean id="jmsTransactionManager"
> >>> >>>> >> >>
> >>> class="org.springframework.jms.connection.JmsTransactionManager">
> >>> >>>> >> >>         <property name="connectionFactory"
> >>> >>>> ref="jmsConnectionFactory"/>
> >>> >>>> >> >>     </bean>
> >>> >>>> >> >>
> >>> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
> >>> Transaction
> >>> >>>> >> Manager
> >>> >>>> >> >> bundle (which in fact uses spring Transaction manager :
> >>> >>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
> >>> >>>> >> >>
> >>> >>>> >> >> I suppose that in the example, the policy is defined by
> default
> >>> by
> >>> >>>> >> spring
> >>> >>>> >> >> when instantiating the class :
> >>> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
> >>> >>>> >> >>
> >>> >>>> >> >> Is it possible to do the same using a JtaTransaction manager
> ?
> >>> >>>> >> >>
> >>> >>>> >> >> Regards,
> >>> >>>> >> >>
> >>> >>>> >> >> Charles Moulliard
> >>> >>>> >> >> Senior Enterprise Architect
> >>> >>>> >> >> Apache Camel Committer
> >>> >>>> >> >>
> >>> >>>> >> >> *****************************
> >>> >>>> >> >> blog : http://cmoulliard.blogspot.com
> >>> >>>> >> >>
> >>> >>>> >> >>
> >>> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
> >>> [hidden email]>
> >>> >>>> >> wrote:
> >>> >>>> >> >>
> >>> >>>> >> >>> Hi
> >>> >>>> >> >>>
> >>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
> >>> >>>> >> >>>
> >>> >>>> >> >>>
> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
> >>> >>>> [hidden email]
> >>> >>>> >> >
> >>> >>>> >> >>> wrote:
> >>> >>>> >> >>> > Camel generates the following error with my route :
> >>> >>>> >> >>> >
> >>> >>>> >> >>> > Route
> >>> >>>> >> >>> >
> >>> >>>> >> >>> >        <camel:route>
> >>> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
> >>> >>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message"
> />
> >>> >>>> >> >>> >            <camel:transacted/>
> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
> >>> >>>> >> method="createNotification"
> >>> >>>> >> >>> />
> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
> >>> method="generateError"
> >>> >>>> />
> >>> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
> >>> >>>> >> >>> >        </camel:route>
> >>> >>>> >> >>> >
> >>> >>>> >> >>> > It seems that policy must be defined but in the example
> here
> >>> it
> >>> >>>> is
> >>> >>>> >> not
> >>> >>>> >> >>> > mentioned :
> >>> http://camel.apache.org/transactional-client.html
> >>> >>>> >> >>> >
> >>> >>>> >> >>> > Error :
> >>> >>>> >> >>> >
> >>> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
> >>> ContextLoaderListener
> >>> >>>> >> >>>    |
> >>> >>>> >> >>> > BundleApplicationContextListener   50 | Application
> context
> >>> >>>> refresh
> >>> >>>> >> >>> failed
> >>> >>>> >> >>> >
> >>> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> >>> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
> >>> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
> >>> >>>> >> >>> java.lang.IllegalArgumentException:
> >>> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
> >>> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
> >>> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy
> must be
> >>> >>>> >> specified
> >>> >>>> >> >>> on:
> >>> >>>> >> >>> > Transacted[ref: null]
> >>> >>>> >> >>> >    at
> >>> >>>> >>
> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
> >>> >>>> >> >>> >    at
> >>> >>>> >>
> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
> >>> >>>> >> >>> >    at
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >>
> >>> >>>>
> >>>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> >>> >>>> >> >>> > Charles Moulliard
> >>> >>>> >> >>> > Senior Enterprise Architect
> >>> >>>> >> >>> > Apache Camel Committer
> >>> >>>> >> >>> >
> >>> >>>> >> >>> > *****************************
> >>> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
> >>> >>>> >> >>> >
> >>> >>>> >> >>>
> >>> >>>> >> >>>
> >>> >>>> >> >>>
> >>> >>>> >> >>> --
> >>> >>>> >> >>> Claus Ibsen
> >>> >>>> >> >>> Apache Camel Committer
> >>> >>>> >> >>>
> >>> >>>> >> >>> Open Source Integration: http://fusesource.com
> >>> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
> >>> >>>> >> >>> Twitter: http://twitter.com/davsclaus
> >>> >>>> >> >>>
> >>> >>>> >> >>
> >>> >>>> >> >>
> >>> >>>> >> >
> >>> >>>> >>
> >>> >>>> >>
> >>> >>>> >>
> >>> >>>> >> --
> >>> >>>> >> Claus Ibsen
> >>> >>>> >> Apache Camel Committer
> >>> >>>> >>
> >>> >>>> >> Open Source Integration: http://fusesource.com
> >>> >>>> >> Blog: http://davsclaus.blogspot.com/
> >>> >>>> >> Twitter: http://twitter.com/davsclaus
> >>> >>>> >>
> >>> >>>> >
> >>> >>>>
> >>> >>>>
> >>> >>>>
> >>> >>>> --
> >>> >>>> Claus Ibsen
> >>> >>>> Apache Camel Committer
> >>> >>>>
> >>> >>>> Open Source Integration: http://fusesource.com
> >>> >>>> Blog: http://davsclaus.blogspot.com/
> >>> >>>> Twitter: http://twitter.com/davsclaus
> >>> >>>>
> >>> >>>
> >>> >>>
> >>> >>
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > Claus Ibsen
> >>> > Apache Camel Committer
> >>> >
> >>> > Open Source Integration: http://fusesource.com
> >>> > Blog: http://davsclaus.blogspot.com/
> >>> > Twitter: http://twitter.com/davsclaus
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Claus Ibsen
> >>> Apache Camel Committer
> >>>
> >>> Open Source Integration: http://fusesource.com
> >>> Blog: http://davsclaus.blogspot.com/
> >>> Twitter: http://twitter.com/davsclaus
> >>>
> >>
> >
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> > ------------------------
> > Open Source SOA
> > http://fusesource.com
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
In debug we see more info :
*
1) Creation has been initiated by TransactionManager*
*15:31:52,484 | DEBUG | tenerContainer-2 | JtaTransactionManager
| stractPlatformTransactionManager  371 | Creating new transaction with name
[null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT*
15:31:52,531 | DEBUG | 9: FileComponent | OsgiPackageScanClassResolver     |
.DefaultPackageScanClassResolver  102 | Found: [class
org.apache.activemq.camel.converter.ActiveMQConverter, class
org.apache.activemq.camel.converter.ActiveMQMessageConverter]
15:31:52,531 | DEBUG | 9: FileComponent | sgiAnnotationTypeConverterLoader |
sgiAnnotationTypeConverterLoader   45 | Loading converter class:
org.apache.activemq.camel.converter.ActiveMQConverter
15:31:52,531 | DEBUG | 9: FileComponent | sgiAnnotationTypeConverterLoader |
sgiAnnotationTypeConverterLoader   45 | Loading converter class:
org.apache.activemq.camel.converter.ActiveMQMessageConverter
15:31:52,546 | DEBUG | 9: FileComponent | ServiceHelper                    |
ctis.x3s.core.util.ServiceHelper   80 | >> Header message Type : 'OINP'
15:31:52,546 | DEBUG | 9: FileComponent | ServiceHelper                    |
ctis.x3s.core.util.ServiceHelper   81 | >> Header CamelFileNameOnly : '
OINP-dummy.txt'
15:31:52,546 | DEBUG | 9: FileComponent | ServiceHelper                    |
ctis.x3s.core.util.ServiceHelper   82 | >> Body : PVI_ID, ORG_ID,
MSG_SEN_CPY_ID, AGT_ID, DEA_CUR_ID, MSG_TGT_CPY_ID, PVI_PRD_TP, FND_IDF_TP,
FND_ID, ORD_DIR_CD, ORG_SEN_TS, ORD_UNT_NB, ORD_CSH_AM
11111,22222,33333,AGENCY23,EUR,44444,PRODUCT2,4,LU1234567890,1,20080107-14:02:09,10,1287.44
99999,88888,77777,AGENCY99,EUR,11111,PRODUCT3,4,LU9874567899,2,20080116-14:02:09,10,1287.44
15:31:52,546 | DEBUG | 9: FileComponent | JtaTransactionManager            |
stractPlatformTransactionManager  469 | Participating in existing
transaction
15:31:52,546 | DEBUG | 9: FileComponent | SessionFactoryUtils              |
m.hibernate3.SessionFactoryUtils  318 | Opening Hibernate Session
15:31:52,546 | DEBUG | 9: FileComponent | SessionImpl                      |
org.hibernate.impl.SessionImpl    247 | opened session at timestamp:
12466279125
15:31:52,546 | DEBUG | 9: FileComponent | SessionFactoryUtils              |
m.hibernate3.SessionFactoryUtils  326 | Registering Spring transaction
synchronization for new Hibernate Session
15:31:52,546 | DEBUG | 9: FileComponent | AbstractSaveEventListener        |
nt.def.AbstractSaveEventListener  320 | executing identity-insert
immediately
15:31:52,546 | DEBUG | 9: FileComponent | AbstractBatcher                  |
g.hibernate.jdbc.AbstractBatcher  410 | about to open PreparedStatement
(open PreparedStatements: 0, globally: 0)
15:31:52,546 | DEBUG | 9: FileComponent | ConnectionManager                |
hibernate.jdbc.ConnectionManager  444 | opening JDBC connection
15:31:52,546 | DEBUG | 9: FileComponent | SQL                              |
ate.jdbc.util.SQLStatementLogger  111 |
    insert
    into
        x3stst.REQUEST
        (FIL_NM, REQ_STU, BODY_TX, REQ_TYP, CRT_USR_NM, CRT_TS, LUP_USR_NM,
LUP_TS)
    values
        (?, ?, ?, ?, ?, ?, ?, ?)
15:31:52,578 | DEBUG | 9: FileComponent | IdentifierGeneratorFactory       |
te.id.IdentifierGeneratorFactory   95 | Natively generated identity: 717
15:31:52,578 | DEBUG | 9: FileComponent | AbstractBatcher                  |
g.hibernate.jdbc.AbstractBatcher  418 | about to close PreparedStatement
(open PreparedStatements: 1, globally: 1)
15:31:52,578 | DEBUG | 9: FileComponent | BeanProcessor                    |
mel.component.bean.BeanProcessor  147 | Setting bean invocation result on
the IN message: com.xpectis.x3s.platform.model.Request@b16f33
15:31:52,578 | INFO  | 9: FileComponent | TraceInterceptor                 |
rg.apache.camel.processor.Logger   88 |
ID-dell-charles-3882-1246606155984-0-603 >>> ref: PROPAGATION_REQUIRED -->
ref: PROPAGATION_REQUIRED, Pattern:InOnly,
Headers:{CamelFileNameOnly=OINP-dummy.txt,
CamelFileRelativePath=d:\temp\data\oinp\OINP-dummy.txt,
CamelFileLastModified=Tue Jun 16 14:50:55 CEST 2009,
CamelFileAbsolutePath=d:\temp\data\oinp\OINP-dummy.txt, origin=file,
CamelBeanMultiParameterArray=false, CamelBeanMethodName=null,
messageType=OINP, CamelFileName=OINP-dummy.txt, CamelFileLength=332,
CamelFilePath=d:\temp\data\oinp\OINP-dummy.txt,
CamelFileParent=d:\temp\data\oinp, CamelFileAbsolute=true},
BodyType:com.xpectis.x3s.platform.model.Request,
Body:com.xpectis.x3s.platform.model.Request@b16f33
15:31:52,578 | DEBUG | 9: FileComponent | DefaultListableBeanFactory       |
tory.support.AbstractBeanFactory  214 | Returning cached instance of
singleton bean 'serviceHelper'
15:31:52,593 | INFO  | 9: FileComponent | TraceInterceptor                 |
rg.apache.camel.processor.Logger  166 |
ID-dell-charles-3882-1246606155984-0-603 >>> ref: PROPAGATION_REQUIRED -->
ref: PROPAGATION_REQUIRED, Pattern:InOnly,
Headers:{CamelFileNameOnly=OINP-dummy.txt,
CamelFileRelativePath=d:\temp\data\oinp\OINP-dummy.txt,
CamelFileLastModified=Tue Jun 16 14:50:55 CEST 2009,
CamelFileAbsolutePath=d:\temp\data\oinp\OINP-dummy.txt, origin=file,
CamelBeanMultiParameterArray=false, CamelBeanMethodName=null,
messageType=OINP, CamelFileName=OINP-dummy.txt, CamelFileLength=332,
CamelFilePath=d:\temp\data\oinp\OINP-dummy.txt,
CamelFileParent=d:\temp\data\oinp, CamelFileAbsolute=true},
BodyType:com.xpectis.x3s.platform.model.Request,
Body:com.xpectis.x3s.platform.model.Request@b16f33, Exception:
java.lang.IllegalArgumentException: Generate error to test rollback
15:31:52,593 | DEBUG | 9: FileComponent | Pipeline                         |
.apache.camel.processor.Pipeline   95 | Message exchange has failed so
breaking out of pipeline: Exchange[GenericFileMessage with body:
com.xpectis.x3s.platform.model.Request@b16f33] exception:
java.lang.IllegalArgumentException: Generate error to test rollback
15:31:52,593 | DEBUG | 9: FileComponent | TransactionErrorHandler          |
rg.apache.camel.processor.Logger  197 | Failed delivery for exchangeId:
ID-dell-charles-3882-1246606155984-0-603. On delivery attempt: 0 caught:
java.lang.IllegalArgumentException: Generate error to test rollback
15:31:52,593 | DEBUG | 9: FileComponent | TransactionErrorHandler          |
processor.RedeliveryErrorHandler  357 | This exchange is not handled so its
marked as failed: Exchange[GenericFileMessage with body:
com.xpectis.x3s.platform.model.Request@b16f33]
*
2) Transaction is setted to rollbackOnly
*
*15:31:52,593 | DEBUG | 9: FileComponent | TransactionErrorHandler
| ng.spi.TransactionErrorHandler$1  127 | Setting transaction to
rollbackOnly due to exception being thrown:
java.lang.IllegalArgumentException: Generate error to test rollback
15:31:52,593 | DEBUG | 9: FileComponent | TransactionTemplate              |
tion.support.TransactionTemplate  152 | Initiating transaction rollback on
application exception
org.apache.camel.spring.spi.TransactedRuntimeCamelException:
java.lang.IllegalArgumentException: Generate error to test rollback*
    at
org.apache.camel.spring.spi.TransactionErrorHandler.wrapTransactedRuntimeException(TransactionErrorHandler.java:170)
    at
org.apache.camel.spring.spi.TransactionErrorHandler$1.doInTransactionWithoutResult(TransactionErrorHandler.java:121)
    at
org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
    at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
    at
org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:86)
    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
    at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
    at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
    at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:148)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
    at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:148)
    at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
    at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
    at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:45)
    at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:65)
    at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:62)
    at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:142)
    at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:62)
    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
    at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
    at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
    at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:148)
    at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
    at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:148)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:73)
    at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
    at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
    at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:198)
    at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:122)
    at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:95)
    at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:98)
    at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
    at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
    at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
    at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: Generate error to test
rollback
    at
com.xpectis.x3s.core.util.ServiceHelper.generateError(ServiceHelper.java:734)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:193)
    at
org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:115)
    at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:118)
    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
    at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
    at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
    at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:148)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
    at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:148)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:73)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.spring.spi.TransactionErrorHandler.access$101(TransactionErrorHandler.java:41)
    at
org.apache.camel.spring.spi.TransactionErrorHandler$1.doInTransactionWithoutResult(TransactionErrorHandler.java:114)
    ... 45 more

*3) Transaction is completed*

*15:31:52,609 | DEBUG | 9: FileComponent | SessionFactoryUtils
| m.hibernate3.SessionFactoryUtils  789 | Closing Hibernate Session
15:31:52,609 | DEBUG | 9: FileComponent | ConnectionManager                |
hibernate.jdbc.ConnectionManager  464 | releasing JDBC connection [ (open
PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
15:31:52,609 | DEBUG | 9: FileComponent | ConnectionManager                |
hibernate.jdbc.ConnectionManager  325 | transaction completed on session
with on_close connection release mode; be sure to close the session to
release JDBC resources!*

*4) Transaction rollbacke initiated*

*15:31:52,609 | DEBUG | 9: FileComponent | JtaTransactionManager
| stractPlatformTransactionManager  821 | Initiating transaction rollback*
15:31:52,609 | INFO  | 9: FileComponent | TraceInterceptor                 |
rg.apache.camel.processor.Logger  166 |
ID-dell-charles-3882-1246606155984-0-603 >>> ref: PROPAGATION_REQUIRED -->
ref: PROPAGATION_REQUIRED, Pattern:InOnly,
Headers:{CamelFileNameOnly=OINP-dummy.txt, CamelFileLastModified=Tue Jun 16
14:50:55 CEST 2009, CamelFileRelativePath=d:\temp\data\oinp\OINP-dummy.txt,
CamelFileAbsolutePath=d:\temp\data\oinp\OINP-dummy.txt, origin=file,
CamelBeanMultiParameterArray=false, CamelRedelivered=false,
messageType=OINP, CamelBeanMethodName=null, CamelFileLength=332,
CamelFileName=OINP-dummy.txt,
CamelFilePath=d:\temp\data\oinp\OINP-dummy.txt,
CamelFileParent=d:\temp\data\oinp, CamelRedeliveryCounter=0,
CamelFileAbsolute=true}, BodyType:com.xpectis.x3s.platform.model.Request,
Body:com.xpectis.x3s.platform.model.Request@b16f33,
Exception:java.lang.IllegalArgumentException: Generate error to test
rollback, Exception:
org.apache.camel.spring.spi.TransactedRuntimeCamelException:
java.lang.IllegalArgumentException: Generate error to test rollback
15:31:52,609 | DEBUG | 9: FileComponent | Pipeline                         |
.apache.camel.processor.Pipeline   95 | Message exchange has failed so
breaking out of pipeline: Exchange[GenericFileMessage with body:
com.xpectis.x3s.platform.model.Request@b16f33] exception:
org.apache.camel.spring.spi.TransactedRuntimeCamelException:
java.lang.IllegalArgumentException: Generate error to test rollback
15:31:52,609 | DEBUG | 9: FileComponent | GenericFileOnCompletion          |
ent.file.GenericFileOnCompletion   75 | Done processing file:
GenericFile[d:\temp\data\oinp\OINP-dummy.txt] using exchange:
Exchange[GenericFileMessage with body:
com.xpectis.x3s.platform.model.Request@b16f33]
15:31:52,609 | ERROR | 9: FileComponent | GenericFileOnCompletion          |
rg.apache.camel.processor.Logger  248 | java.lang.IllegalArgumentException:
Generate error to test rollback
org.apache.camel.spring.spi.TransactedRuntimeCamelException:
java.lang.IllegalArgumentException: Generate error to test rollback
    at
org.apache.camel.spring.spi.TransactionErrorHandler.wrapTransactedRuntimeException(TransactionErrorHandler.java:170)
    at
org.apache.camel.spring.spi.TransactionErrorHandler$1.doInTransactionWithoutResult(TransactionErrorHandler.java:121)
    at
org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
    at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
    at
org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:86)
    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
    at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
    at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
    at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:148)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
    at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:148)
    at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
    at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
    at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:45)
    at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:65)
    at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:62)
    at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:142)
    at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:62)
    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
    at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
    at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
    at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:148)
    at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
    at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:148)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:73)
    at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
    at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
    at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:198)
    at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:122)
    at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:95)
    at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:98)
    at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
    at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
    at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
    at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: Generate error to test
rollback
    at
com.xpectis.x3s.core.util.ServiceHelper.generateError(ServiceHelper.java:734)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:193)
    at
org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:115)
    at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:118)
    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
    at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
    at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
    at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:148)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
    at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:148)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:73)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:189)
    at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:158)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
    at
org.apache.camel.spring.spi.TransactionErrorHandler.access$101(TransactionErrorHandler.java:41)
    at
org.apache.camel.spring.spi.TransactionErrorHandler$1.doInTransactionWithoutResult(TransactionErrorHandler.java:114)
    ... 45 more

*Rollback for the FILE*

*15:31:52,609 | WARN  | 9: FileComponent | GenericFileOnCompletion
| ent.file.GenericFileOnCompletion  137 | Rolling back remote file *strategy:
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@1b735a1for
file: GenericFile[d:\temp\data\oinp\OINP-dummy.txt]

Strange what we have here

15:31:53,250 | DEBUG | tenerContainer-3 | JtaTransactionManager            |
stractPlatformTransactionManager  730 | Initiating transaction commit
15:31:53,265 | DEBUG | tenerContainer-4 | JtaTransactionManager            |
stractPlatformTransactionManager  371 | Creating new transaction with name
[null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
15:31:53,359 | DEBUG | tenerContainer-2 | JtaTransactionManager            |
stractPlatformTransactionManager  730 | Initiating transaction commit
15:31:53,390 | DEBUG | tenerContainer-3 | JtaTransactionManager            |
stractPlatformTransactionManager  371 | Creating new transaction with name
[null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
15:31:53,468 | DEBUG | tenerContainer-3 | JtaTransactionManager            |
stractPlatformTransactionManager  730 | Initiating transaction commit
15:31:53,468 | DEBUG | tenerContainer-4 | JtaTransactionManager            |
stractPlatformTransactionManager  371 | Creating new transaction with name
[null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
15:31:53,484 | DEBUG | tenerContainer-2 | JtaTransactionManager            |
stractPlatformTransactionManager  730 | Initiating transaction commit
15:31:53,484 | DEBUG | tenerContainer-3 | JtaTransactionManager            |
stractPlatformTransactionManager  371 | Creating new transaction with name
[null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
15:31:53,500 | DEBUG | nitor W

But the transaction with the DB is not rollbacked

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jul 3, 2009 at 3:26 PM, Charles Moulliard <[hidden email]>wrote:

> I have created a small route without JMS stuff.
>
> Here is the route :
>
>         <camel:route>
>             <camel:from ref="fileClientEndpoint" />
>
>             <camel:setHeader headerName="origin">
>                 <camel:constant>file</camel:constant>
>             </camel:setHeader>
>             <camel:setHeader headerName="messageType">
>                 <camel:constant>OINP</camel:constant>
>             </camel:setHeader>
>             <camel:convertBodyTo type="java.lang.String"/>
>             <camel:to ref="directRequestEndpoint" />
>         </camel:route>
>
>         <camel:route>
>             <camel:from ref="directRequestEndpoint" />
>             <camel:transacted ref="PROPAGATION_REQUIRED"/>
>             <!-- Call the requestService to save the request -->
>             <camel:bean ref="serviceHelper" method="createRequest"/>
>             <camel:bean ref="serviceHelper" method="generateError" />
>             <camel:to uri="direct:testTx"/>
>         </camel:route>
>
> Unfortunately when a throw error is generated in bean called
> "generateError"
>
>     public void generateError() {
>             throw new IllegalArgumentException("Generate error to test
> rollback");
>     }
>
> records are committed in the DB and not rollbacked
>
>
> I see that when the error is throw the message is redelivered a second time
> as this parameter has been defined in the ActiveMq
>
>     <bean id="x3sPolicy" class="org.apache.activemq.RedeliveryPolicy">
> *        <property name="maximumRedeliveries" value="1"/>*
>     </bean>
>
>     <bean id="activemqConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL" value="tcp://localhost:61616" />
>         <property name="redeliveryPolicy" ref="x3sPolicy"/>
>     </bean>
>
> Question :  Why policy defined in the ActiveMq is taken into account here ?
> Why the rollback does not occur ?
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jul 3, 2009 at 12:28 PM, Claus Ibsen <[hidden email]>wrote:
>
>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<[hidden email]> wrote:
>> > In this case, you should not use transactions for the DB at all, but
>> > if any error occurs while saving the data, an exception should be
>> > thrown and should rollback the transaction for the JMS layer.
>> Yeah that would be perfect unless he does some work afterwards the DB
>> and that throws an Exception.
>> Then the DB layer have already committed.
>>
>> So trying to avoid doing work after the DB layer would help.
>>
>>
>> Is this not possible?
>> But he is doing JPA/Hibernte stuff so he could grab the "session" and
>> invoke a rollback manually in case errors happen afterwards.
>>
>>
>>
>>
>> >
>> > On Fri, Jul 3, 2009 at 10:48, Charles Moulliard<[hidden email]>
>> wrote:
>> >> Claus,
>> >>
>> >> I don't want at all to use XA transaction. Correct me if I'm wrong but
>> the
>> >> example of the documentation (Camel 2.0 - JMS Sample - part Spring XML)
>> does
>> >> not use at all a XA driver and the message will not be removed from the
>> >> queue if a rollback occurs in the bean MyProcessor ?
>> >>
>> >> My concern is to avoid to lost messages from a file, queues if
>> something
>> >> happen in one of the services called where by example we have to save
>> data
>> >> in a DB or generate a report for a client. If such errors occur, then
>> we
>> >> have to investigate why can't save data in DB (maybe related to a
>> connection
>> >> issue, DB shutdown, ...) or generates files (maybe due to disk full,
>> access
>> >> right, ....). Sometimes, this is related to conditions out of the
>> control of
>> >> our application but sometimes no, then we have to correct the error and
>> >> install a new version of the code. After the restart of the application
>> and
>> >> recovery of messages (persisted in the case of activemq), messages will
>> be
>> >> reprocessed.
>> >>
>> >> Regards,
>> >>
>> >> Charles Moulliard
>> >> Senior Enterprise Architect
>> >> Apache Camel Committer
>> >>
>> >> *****************************
>> >> blog : http://cmoulliard.blogspot.com
>> >>
>> >>
>> >> On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]>
>> wrote:
>> >>
>> >>> And reconsider if you need XA at all. Its slow and hard to get setup.
>> >>>
>> >>> Try to let the DB be the last stuff you do and afterwards send the
>> >>> message to another queue for further processing in a 2nd route.
>> >>> If that is possible in your use-case.
>> >>>
>> >>>
>> >>> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]>
>> wrote:
>> >>> > Hi
>> >>> >
>> >>> > Get it working outside OSGi, eg in a small unit test thats easy to
>> run
>> >>> > and test from within your IDE.
>> >>> > Google for JMS + hibernate + TX + XA to find some samples that work.
>> >>> >
>> >>> > And since you use JMS + DB in the same TX you need to use XA db
>> driver.
>> >>> >
>> >>> > It can be a painful to get setup
>> >>> >
>> >>>
>> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
>> >>> >
>> >>> > And you need an XA TX manager such as JOTM
>> >>> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
>> >>> >
>> >>> > In j2ee land there was a JTA with the container that could do it.
>> But
>> >>> > in your OSGi container I do not know if it provides one out of the
>> >>> > box.
>> >>> >
>> >>> >
>> >>> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<
>> [hidden email]>
>> >>> wrote:
>> >>> >> I'm still fighting against Spring config or Camel because Rollback
>> does
>> >>> not
>> >>> >> occur. I have been able to configure Hibernate to use the same
>> >>> >> TransactionManager as the one used by JMS
>> >>> >>
>> >>> >> Here is the different part of the config. I don't know where the
>> issue
>> >>> could
>> >>> >> be !
>> >>> >>
>> >>> >> 1) ActiveMQ
>> >>> >>
>> >>> >> ...
>> >>> >>
>> >>> >>    <bean id="activemqConnectionFactory"
>> >>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >>> >>        <property name="brokerURL" value="tcp://localhost:61616" />
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="pooledConnectionFactory"
>> >>> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
>> >>> >>        <property name="maxConnections" value="8" />
>> >>> >>        <property name="maximumActive" value="500" />
>> >>> >>        <property name="transactionManager" ref="transactionManager"
>> />
>> >>> >>        <property name="connectionFactory"
>> >>> ref="activemqConnectionFactory"
>> >>> >> />
>> >>> >>        <property name="resourceName" value="activemq.default" />
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="resourceManager"
>> >>> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
>> >>> >> init-method="recoverResource">
>> >>> >>          <property name="transactionManager"
>> ref="transactionManager" />
>> >>> >>          <property name="connectionFactory"
>> >>> ref="activemqConnectionFactory"
>> >>> >> />
>> >>> >>          <property name="resourceName" value="activemq.default" />
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <osgi:reference id="transactionManager"
>> >>> >> interface="javax.transaction.TransactionManager" /> // This OSGI
>> service
>> >>> is
>> >>> >> published by Geronimo Transaction bundle
>> >>> >>
>> >>> >>    <osgi:service ref="pooledConnectionFactory">
>> >>> >>        <osgi:interfaces>
>> >>> >>            <value>javax.jms.ConnectionFactory</value>
>> >>> >>        </osgi:interfaces>
>> >>> >>        <osgi:service-properties>
>> >>> >>            <entry key="name" value="default"/>
>> >>> >>        </osgi:service-properties>
>> >>> >>    </osgi:service>
>> >>> >>
>> >>> >> 2) Camel ActiveMQComponent
>> >>> >>
>> >>> >>    <bean id="active-mq"
>> >>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >>> >>        <property name="transacted" value="true"/>
>> >>> >>        <property name="connectionFactory">
>> >>> >>            <osgi:reference
>> interface="javax.jms.ConnectionFactory"/> //
>> >>> >> OSGI service is published by ActiveMQ service
>> >>> >>        </property>
>> >>> >>        <property name="transactionManager">
>> >>> >>            <osgi:reference
>> >>> >>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >> 2) Hibernate - DAO
>> >>> >>
>> >>> >>    <bean id="sessionFactory"
>> >>> >> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>> >>> >>
>> >>> >>        <property name="mappingLocations">
>> >>> >>            <list>
>> >>> >>
>> >>> >>
>> >>>
>> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
>> >>> >>            </list>
>> >>> >>        </property>
>> >>> >>
>> >>> >>        <property name="hibernateProperties">
>> >>> >>            <props>
>> >>> >>                <prop
>> >>> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>> >>> >>                <prop key="hibernate.show_sql">true</prop>
>> >>> >>                <prop key="hibernate.format_sql">true</prop>
>> >>> >>                <prop
>> >>> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>> >>> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
>> >>> >>                <prop
>> >>> >>
>> >>>
>> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
>> >>> >>                <prop
>> >>> >>
>> >>>
>> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
>> >>> >>            </props>
>> >>> >>        </property>
>> >>> >>        <property name="dataSource">
>> >>> >>            <ref bean="dataSource" />
>> >>> >>        </property>
>> >>> >>
>> >>> >> Remark : To avoid the JNDI lookup issue, we use
>> springTransactionFactory
>> >>> as
>> >>> >> the TransactionFactory for Hibernate (
>> >>> >> http://forum.springsource.org/showthread.php?p=215720)
>> >>> >>
>> >>> >> 3) Service layer
>> >>> >>
>> >>> >> Here is the definition of the service used from Camel route :
>> >>> >>
>> >>> >>    <bean id="notificationServiceTarget"
>> >>> >>
>> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
>> >>> >>            <property name="notificationDAO">
>> >>> >>            <osgi:reference
>> >>> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
>> >>> >>        </property>
>> >>> >>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>   <!-- Abstract service using the Geronimo Transaction Manager -->
>> >>> >>    <bean id="abstractService" abstract="true"
>> >>> >>
>> >>>
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>> >>> >>         <property name="transactionManager">
>> >>> >>            <osgi:reference
>> >>> >>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="notificationService"
>> >>> >>          parent="abstractService"
>> >>> >>
>> >>> >>
>> >>>
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>> >>> >>
>> >>> >>        <property name="target">
>> >>> >>            <ref bean="notificationServiceTarget" />
>> >>> >>        </property>
>> >>> >>
>> >>> >>        <property name="transactionAttributes">
>> >>> >>            <props>
>> >>> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
>> >>> >>            </props>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >> 4) Route
>> >>> >>
>> >>> >>    <bean id="myPolicy"
>> >>> class="org.apache.camel.processor.RedeliveryPolicy">
>> >>> >>        <property name="maximumRedeliveries" value="1"/>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="txErrorHandler"
>> >>> >> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>> >>> >>        <property name="springTransactionPolicy"
>> >>> >> ref="PROPAGATION_REQUIRED"/>
>> >>> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="PROPAGATION_REQUIRED"
>> >>> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >>> >>        <property name="transactionManager">
>> >>> >>            <osgi:reference
>> >>> >>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>        <camel:route errorHandlerRef="txErrorHandler">
>> >>> >>            <camel:from ref="queueQuickFixInEndpoint" />
>> >>> >>            <camel:convertBodyTo type="quickfix.Message" />
>> >>> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>> >>> >>            <camel:bean ref="serviceHelper"
>> method="createNotification"
>> >>> />
>> >>> >>            <camel:bean ref="serviceHelper" method="generateError"
>> />
>> >>> >>            <camel:to ref="directNotificationEndpoint" />
>> >>> >>        </camel:route>
>> >>> >>
>> >>> >> Any ideas are welcome
>> >>> >>
>> >>> >> Regards,
>> >>> >>
>> >>> >> Charles Moulliard
>> >>> >> Senior Enterprise Architect
>> >>> >> Apache Camel Committer
>> >>> >>
>> >>> >> *****************************
>> >>> >> blog : http://cmoulliard.blogspot.com
>> >>> >>
>> >>> >>
>> >>> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <
>> [hidden email]
>> >>> >wrote:
>> >>> >>
>> >>> >>> OK. I will try to create my own Hibernate JTATransaction manager
>> as the
>> >>> >>> existing try to perform a JNDI lookup to find the transaction
>> manager
>> >>> on
>> >>> >>> OSGI platform (inheritage from J2EE world)
>> >>> >>>
>> >>> >>>
>> >>> >>>
>> >>>
>> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>> >>> >>>
>> >>> >>>
>> >>> >>> Charles Moulliard
>> >>> >>> Senior Enterprise Architect
>> >>> >>> Apache Camel Committer
>> >>> >>>
>> >>> >>> *****************************
>> >>> >>> blog : http://cmoulliard.blogspot.com
>> >>> >>>
>> >>> >>>
>> >>> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <
>> [hidden email]>
>> >>> wrote:
>> >>> >>>
>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>> >>> [hidden email]>
>> >>> >>>> wrote:
>> >>> >>>> > queueQuickFixInEndpoint is a JMS queue.
>> >>> >>>> >
>> >>> >>>> > I will add the ref to the transacted and retest
>> >>> >>>> >
>> >>> >>>> > Question : I suppose that rollback will not occur if by example
>> JMS
>> >>> and
>> >>> >>>> DB
>> >>> >>>> > (=Hibernate) does not use the same TransactionManager and don't
>> use
>> >>> this
>> >>> >>>> > spring class together :
>> >>> >>>> > org.springframework.transaction.PlatformTransactionManager
>> >>> >>>> Yes they must be configured to use the same TX manager.
>> >>> >>>>
>> >>> >>>>
>> >>> >>>> >
>> >>> >>>> > Regards,
>> >>> >>>> >
>> >>> >>>> > Charles Moulliard
>> >>> >>>> > Senior Enterprise Architect
>> >>> >>>> > Apache Camel Committer
>> >>> >>>> >
>> >>> >>>> > *****************************
>> >>> >>>> > blog : http://cmoulliard.blogspot.com
>> >>> >>>> >
>> >>> >>>> >
>> >>> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <
>> [hidden email]>
>> >>> >>>> wrote:
>> >>> >>>> >
>> >>> >>>> >> Transacted also have a ref attribute
>> >>> >>>> >>
>> >>> >>>> >> <transacted ref="required"/>
>> >>> >>>> >>
>> >>> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
>> >>> >>>> >> You need to use a TX manager that can do both JMS and DB.
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
>> >>> [hidden email]
>> >>> >>>> >
>> >>> >>>> >> wrote:
>> >>> >>>> >> > I have been able to solve my problem by adding the following
>> bean
>> >>> >>>> >> definition
>> >>> >>>> >> > :
>> >>> >>>> >> >
>> >>> >>>> >> >    <bean id="required"
>> >>> >>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >>> >>>> >> >        <property name="transactionManager">
>> >>> >>>> >> >            <osgi:reference
>> >>> >>>> >> >
>> >>> >>>>
>> >>>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>>> >> >        </property>
>> >>> >>>> >> >    </bean>
>> >>> >>>> >> >
>> >>> >>>> >> > and in the route
>> >>> >>>> >> >
>> >>> >>>> >> >        <camel:route>
>> >>> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >>> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>> >>> >>>> >> >            <camel:transacted/>
>> >>> >>>> >> >            <camel:policy ref="required" />
>> >>> >>>> >> >            <camel:bean ref="serviceHelper"
>> >>> >>>> method="createNotification" />
>> >>> >>>> >> >            <camel:bean ref="serviceHelper"
>> method="generateError"
>> >>> />
>> >>> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
>> >>> >>>> >> >        </camel:route>
>> >>> >>>> >> >
>> >>> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
>> >>> records
>> >>> >>>> have
>> >>> >>>> >> been
>> >>> >>>> >> > created by the method createNotification when error has been
>> >>> raised
>> >>> >>>> by
>> >>> >>>> >> the
>> >>> >>>> >> > method generateError.
>> >>> >>>> >> >
>> >>> >>>> >> > What is missing ?
>> >>> >>>> >> >
>> >>> >>>> >> > Charles Moulliard
>> >>> >>>> >> > Senior Enterprise Architect
>> >>> >>>> >> > Apache Camel Committer
>> >>> >>>> >> >
>> >>> >>>> >> > *****************************
>> >>> >>>> >> > blog : http://cmoulliard.blogspot.com
>> >>> >>>> >> >
>> >>> >>>> >> >
>> >>> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>> >>> >>>> [hidden email]
>> >>> >>>> >> >wrote:
>> >>> >>>> >> >
>> >>> >>>> >> >> When I compare the example :
>> >>> JMSTransactionalClientRollbackTest.xml
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- START SNIPPET: e1 -->
>> >>> >>>> >> >>     <!-- setup JMS connection factory -->
>> >>> >>>> >> >>     <bean id="jmsConnectionFactory"
>> >>> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >>> >>>> >> >>         <property name="brokerURL"
>> >>> >>>> >> >>
>> >>> >>>>
>> >>>
>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
>> >>> >>>> >> >>     <bean id="jmsTransactionManager"
>> >>> >>>> >> >>
>> >>> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>> >>>> >> >>         <property name="connectionFactory"
>> >>> >>>> ref="jmsConnectionFactory"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- define our activemq component -->
>> >>> >>>> >> >>     <bean id="activemq"
>> >>> >>>> >> >>
>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >>> >>>> >> >>         <property name="connectionFactory"
>> >>> >>>> ref="jmsConnectionFactory"/>
>> >>> >>>> >> >>         <!-- define the jms consumer/producer as transacted
>> -->
>> >>> >>>> >> >>         <property name="transacted" value="true"/>
>> >>> >>>> >> >>         <!-- setup the transaction manager to use -->
>> >>> >>>> >> >>         <!-- if not provided then Camel will automatic use
>> a
>> >>> >>>> >> >> JmsTransactionManager, however if you
>> >>> >>>> >> >>              for instance use a JTA transaction manager
>> then you
>> >>> >>>> must
>> >>> >>>> >> >> configure it -->
>> >>> >>>> >> >>         <property name="transactionManager"
>> >>> >>>> >> ref="jmsTransactionManager"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>     <!-- END SNIPPET: e1 -->
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- START SNIPPET: e2 -->
>> >>> >>>> >> >>     <camelContext xmlns="
>> http://camel.apache.org/schema/spring
>> >>> ">
>> >>> >>>> >> >>         <route>
>> >>> >>>> >> >>             <!-- 1: from the jms queue -->
>> >>> >>>> >> >>             <from uri="activemq:queue:okay"/>
>> >>> >>>> >> >>             <!-- 2: mark this route as transacted -->
>> >>> >>>> >> >>             <transacted/>
>> >>> >>>> >> >>             <!-- 3: call our business logic that is
>> myProcessor
>> >>> -->
>> >>> >>>> >> >>             <process ref="myProcessor"/>
>> >>> >>>> >> >>             <!-- 4: if success then send it to the mock -->
>> >>> >>>> >> >>             <to uri="mock:result"/>
>> >>> >>>> >> >>         </route>
>> >>> >>>> >> >>     </camelContext>
>> >>> >>>> >> >>
>> >>> >>>> >> >> with mine.
>> >>> >>>> >> >>
>> >>> >>>> >> >> What is different concerns the TransactionManager used.
>> >>> >>>> >> >>
>> >>> >>>> >> >> In the example, this is the Spring one:
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
>> >>> >>>> >> >>     <bean id="jmsTransactionManager"
>> >>> >>>> >> >>
>> >>> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>> >>>> >> >>         <property name="connectionFactory"
>> >>> >>>> ref="jmsConnectionFactory"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>
>> >>> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
>> >>> Transaction
>> >>> >>>> >> Manager
>> >>> >>>> >> >> bundle (which in fact uses spring Transaction manager :
>> >>> >>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>> >>> >>>> >> >>
>> >>> >>>> >> >> I suppose that in the example, the policy is defined by
>> default
>> >>> by
>> >>> >>>> >> spring
>> >>> >>>> >> >> when instantiating the class :
>> >>> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
>> >>> >>>> >> >>
>> >>> >>>> >> >> Is it possible to do the same using a JtaTransaction
>> manager ?
>> >>> >>>> >> >>
>> >>> >>>> >> >> Regards,
>> >>> >>>> >> >>
>> >>> >>>> >> >> Charles Moulliard
>> >>> >>>> >> >> Senior Enterprise Architect
>> >>> >>>> >> >> Apache Camel Committer
>> >>> >>>> >> >>
>> >>> >>>> >> >> *****************************
>> >>> >>>> >> >> blog : http://cmoulliard.blogspot.com
>> >>> >>>> >> >>
>> >>> >>>> >> >>
>> >>> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
>> >>> [hidden email]>
>> >>> >>>> >> wrote:
>> >>> >>>> >> >>
>> >>> >>>> >> >>> Hi
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
>> >>> >>>> >> >>>
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>> >>> >>>> [hidden email]
>> >>> >>>> >> >
>> >>> >>>> >> >>> wrote:
>> >>> >>>> >> >>> > Camel generates the following error with my route :
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > Route
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> >        <camel:route>
>> >>> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >>> >>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message"
>> />
>> >>> >>>> >> >>> >            <camel:transacted/>
>> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>> >>> >>>> >> method="createNotification"
>> >>> >>>> >> >>> />
>> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>> >>> method="generateError"
>> >>> >>>> />
>> >>> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>> >>> >>>> >> >>> >        </camel:route>
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > It seems that policy must be defined but in the example
>> here
>> >>> it
>> >>> >>>> is
>> >>> >>>> >> not
>> >>> >>>> >> >>> > mentioned :
>> >>> http://camel.apache.org/transactional-client.html
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > Error :
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
>> >>> ContextLoaderListener
>> >>> >>>> >> >>>    |
>> >>> >>>> >> >>> > BundleApplicationContextListener   50 | Application
>> context
>> >>> >>>> refresh
>> >>> >>>> >> >>> failed
>> >>> >>>> >> >>> >
>> >>> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>> >>> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>> >>> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
>> >>> >>>> >> >>> java.lang.IllegalArgumentException:
>> >>> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>> >>> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>> >>> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy
>> must be
>> >>> >>>> >> specified
>> >>> >>>> >> >>> on:
>> >>> >>>> >> >>> > Transacted[ref: null]
>> >>> >>>> >> >>> >    at
>> >>> >>>> >>
>> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >>
>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>> >>> >>>> >> >>> > Charles Moulliard
>> >>> >>>> >> >>> > Senior Enterprise Architect
>> >>> >>>> >> >>> > Apache Camel Committer
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > *****************************
>> >>> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >> >>>
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> --
>> >>> >>>> >> >>> Claus Ibsen
>> >>> >>>> >> >>> Apache Camel Committer
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> Open Source Integration: http://fusesource.com
>> >>> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
>> >>> >>>> >> >>> Twitter: http://twitter.com/davsclaus
>> >>> >>>> >> >>>
>> >>> >>>> >> >>
>> >>> >>>> >> >>
>> >>> >>>> >> >
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >> --
>> >>> >>>> >> Claus Ibsen
>> >>> >>>> >> Apache Camel Committer
>> >>> >>>> >>
>> >>> >>>> >> Open Source Integration: http://fusesource.com
>> >>> >>>> >> Blog: http://davsclaus.blogspot.com/
>> >>> >>>> >> Twitter: http://twitter.com/davsclaus
>> >>> >>>> >>
>> >>> >>>> >
>> >>> >>>>
>> >>> >>>>
>> >>> >>>>
>> >>> >>>> --
>> >>> >>>> Claus Ibsen
>> >>> >>>> Apache Camel Committer
>> >>> >>>>
>> >>> >>>> Open Source Integration: http://fusesource.com
>> >>> >>>> Blog: http://davsclaus.blogspot.com/
>> >>> >>>> Twitter: http://twitter.com/davsclaus
>> >>> >>>>
>> >>> >>>
>> >>> >>>
>> >>> >>
>> >>> >
>> >>> >
>> >>> >
>> >>> > --
>> >>> > Claus Ibsen
>> >>> > Apache Camel Committer
>> >>> >
>> >>> > Open Source Integration: http://fusesource.com
>> >>> > Blog: http://davsclaus.blogspot.com/
>> >>> > Twitter: http://twitter.com/davsclaus
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Claus Ibsen
>> >>> Apache Camel Committer
>> >>>
>> >>> Open Source Integration: http://fusesource.com
>> >>> Blog: http://davsclaus.blogspot.com/
>> >>> Twitter: http://twitter.com/davsclaus
>> >>>
>> >>
>> >
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> > ------------------------
>> > Open Source SOA
>> > http://fusesource.com
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Guillaume Nodet
Administrator
In reply to this post by Charles Moulliard
If the message is redelivered, this means there is a rollback.
I guess the problem is that your DB is not enlisted in the transaction.
However, if you don't want to use XA and two phase commit, you should
try to perform the database step as late as possible so that there is very few
chances that anything wrong happen after the data has been written to the DB.
Btw, in your route, I don't see at which step the message is written
to the DB ... ?

On Fri, Jul 3, 2009 at 15:26, Charles Moulliard<[hidden email]> wrote:

> I have created a small route without JMS stuff.
>
> Here is the route :
>
>        <camel:route>
>            <camel:from ref="fileClientEndpoint" />
>
>            <camel:setHeader headerName="origin">
>                <camel:constant>file</camel:constant>
>            </camel:setHeader>
>            <camel:setHeader headerName="messageType">
>                <camel:constant>OINP</camel:constant>
>            </camel:setHeader>
>            <camel:convertBodyTo type="java.lang.String"/>
>            <camel:to ref="directRequestEndpoint" />
>        </camel:route>
>
>        <camel:route>
>            <camel:from ref="directRequestEndpoint" />
>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>            <!-- Call the requestService to save the request -->
>            <camel:bean ref="serviceHelper" method="createRequest"/>
>            <camel:bean ref="serviceHelper" method="generateError" />
>            <camel:to uri="direct:testTx"/>
>        </camel:route>
>
> Unfortunately when a throw error is generated in bean called "generateError"
>
>    public void generateError() {
>            throw new IllegalArgumentException("Generate error to test
> rollback");
>    }
>
> records are committed in the DB and not rollbacked
>
>
> I see that when the error is throw the message is redelivered a second time
> as this parameter has been defined in the ActiveMq
>
>    <bean id="x3sPolicy" class="org.apache.activemq.RedeliveryPolicy">
> *        <property name="maximumRedeliveries" value="1"/>*
>    </bean>
>
>    <bean id="activemqConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>        <property name="brokerURL" value="tcp://localhost:61616" />
>        <property name="redeliveryPolicy" ref="x3sPolicy"/>
>    </bean>
>
> Question :  Why policy defined in the ActiveMq is taken into account here ?
> Why the rollback does not occur ?
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jul 3, 2009 at 12:28 PM, Claus Ibsen <[hidden email]> wrote:
>
>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<[hidden email]> wrote:
>> > In this case, you should not use transactions for the DB at all, but
>> > if any error occurs while saving the data, an exception should be
>> > thrown and should rollback the transaction for the JMS layer.
>> Yeah that would be perfect unless he does some work afterwards the DB
>> and that throws an Exception.
>> Then the DB layer have already committed.
>>
>> So trying to avoid doing work after the DB layer would help.
>>
>>
>> Is this not possible?
>> But he is doing JPA/Hibernte stuff so he could grab the "session" and
>> invoke a rollback manually in case errors happen afterwards.
>>
>>
>>
>>
>> >
>> > On Fri, Jul 3, 2009 at 10:48, Charles Moulliard<[hidden email]>
>> wrote:
>> >> Claus,
>> >>
>> >> I don't want at all to use XA transaction. Correct me if I'm wrong but
>> the
>> >> example of the documentation (Camel 2.0 - JMS Sample - part Spring XML)
>> does
>> >> not use at all a XA driver and the message will not be removed from the
>> >> queue if a rollback occurs in the bean MyProcessor ?
>> >>
>> >> My concern is to avoid to lost messages from a file, queues if something
>> >> happen in one of the services called where by example we have to save
>> data
>> >> in a DB or generate a report for a client. If such errors occur, then we
>> >> have to investigate why can't save data in DB (maybe related to a
>> connection
>> >> issue, DB shutdown, ...) or generates files (maybe due to disk full,
>> access
>> >> right, ....). Sometimes, this is related to conditions out of the
>> control of
>> >> our application but sometimes no, then we have to correct the error and
>> >> install a new version of the code. After the restart of the application
>> and
>> >> recovery of messages (persisted in the case of activemq), messages will
>> be
>> >> reprocessed.
>> >>
>> >> Regards,
>> >>
>> >> Charles Moulliard
>> >> Senior Enterprise Architect
>> >> Apache Camel Committer
>> >>
>> >> *****************************
>> >> blog : http://cmoulliard.blogspot.com
>> >>
>> >>
>> >> On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]>
>> wrote:
>> >>
>> >>> And reconsider if you need XA at all. Its slow and hard to get setup.
>> >>>
>> >>> Try to let the DB be the last stuff you do and afterwards send the
>> >>> message to another queue for further processing in a 2nd route.
>> >>> If that is possible in your use-case.
>> >>>
>> >>>
>> >>> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]>
>> wrote:
>> >>> > Hi
>> >>> >
>> >>> > Get it working outside OSGi, eg in a small unit test thats easy to
>> run
>> >>> > and test from within your IDE.
>> >>> > Google for JMS + hibernate + TX + XA to find some samples that work.
>> >>> >
>> >>> > And since you use JMS + DB in the same TX you need to use XA db
>> driver.
>> >>> >
>> >>> > It can be a painful to get setup
>> >>> >
>> >>>
>> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
>> >>> >
>> >>> > And you need an XA TX manager such as JOTM
>> >>> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
>> >>> >
>> >>> > In j2ee land there was a JTA with the container that could do it. But
>> >>> > in your OSGi container I do not know if it provides one out of the
>> >>> > box.
>> >>> >
>> >>> >
>> >>> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<
>> [hidden email]>
>> >>> wrote:
>> >>> >> I'm still fighting against Spring config or Camel because Rollback
>> does
>> >>> not
>> >>> >> occur. I have been able to configure Hibernate to use the same
>> >>> >> TransactionManager as the one used by JMS
>> >>> >>
>> >>> >> Here is the different part of the config. I don't know where the
>> issue
>> >>> could
>> >>> >> be !
>> >>> >>
>> >>> >> 1) ActiveMQ
>> >>> >>
>> >>> >> ...
>> >>> >>
>> >>> >>    <bean id="activemqConnectionFactory"
>> >>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >>> >>        <property name="brokerURL" value="tcp://localhost:61616" />
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="pooledConnectionFactory"
>> >>> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
>> >>> >>        <property name="maxConnections" value="8" />
>> >>> >>        <property name="maximumActive" value="500" />
>> >>> >>        <property name="transactionManager" ref="transactionManager"
>> />
>> >>> >>        <property name="connectionFactory"
>> >>> ref="activemqConnectionFactory"
>> >>> >> />
>> >>> >>        <property name="resourceName" value="activemq.default" />
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="resourceManager"
>> >>> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
>> >>> >> init-method="recoverResource">
>> >>> >>          <property name="transactionManager"
>> ref="transactionManager" />
>> >>> >>          <property name="connectionFactory"
>> >>> ref="activemqConnectionFactory"
>> >>> >> />
>> >>> >>          <property name="resourceName" value="activemq.default" />
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <osgi:reference id="transactionManager"
>> >>> >> interface="javax.transaction.TransactionManager" /> // This OSGI
>> service
>> >>> is
>> >>> >> published by Geronimo Transaction bundle
>> >>> >>
>> >>> >>    <osgi:service ref="pooledConnectionFactory">
>> >>> >>        <osgi:interfaces>
>> >>> >>            <value>javax.jms.ConnectionFactory</value>
>> >>> >>        </osgi:interfaces>
>> >>> >>        <osgi:service-properties>
>> >>> >>            <entry key="name" value="default"/>
>> >>> >>        </osgi:service-properties>
>> >>> >>    </osgi:service>
>> >>> >>
>> >>> >> 2) Camel ActiveMQComponent
>> >>> >>
>> >>> >>    <bean id="active-mq"
>> >>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >>> >>        <property name="transacted" value="true"/>
>> >>> >>        <property name="connectionFactory">
>> >>> >>            <osgi:reference interface="javax.jms.ConnectionFactory"/>
>> //
>> >>> >> OSGI service is published by ActiveMQ service
>> >>> >>        </property>
>> >>> >>        <property name="transactionManager">
>> >>> >>            <osgi:reference
>> >>> >>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >> 2) Hibernate - DAO
>> >>> >>
>> >>> >>    <bean id="sessionFactory"
>> >>> >> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>> >>> >>
>> >>> >>        <property name="mappingLocations">
>> >>> >>            <list>
>> >>> >>
>> >>> >>
>> >>>
>> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
>> >>> >>            </list>
>> >>> >>        </property>
>> >>> >>
>> >>> >>        <property name="hibernateProperties">
>> >>> >>            <props>
>> >>> >>                <prop
>> >>> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>> >>> >>                <prop key="hibernate.show_sql">true</prop>
>> >>> >>                <prop key="hibernate.format_sql">true</prop>
>> >>> >>                <prop
>> >>> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>> >>> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
>> >>> >>                <prop
>> >>> >>
>> >>>
>> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
>> >>> >>                <prop
>> >>> >>
>> >>>
>> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
>> >>> >>            </props>
>> >>> >>        </property>
>> >>> >>        <property name="dataSource">
>> >>> >>            <ref bean="dataSource" />
>> >>> >>        </property>
>> >>> >>
>> >>> >> Remark : To avoid the JNDI lookup issue, we use
>> springTransactionFactory
>> >>> as
>> >>> >> the TransactionFactory for Hibernate (
>> >>> >> http://forum.springsource.org/showthread.php?p=215720)
>> >>> >>
>> >>> >> 3) Service layer
>> >>> >>
>> >>> >> Here is the definition of the service used from Camel route :
>> >>> >>
>> >>> >>    <bean id="notificationServiceTarget"
>> >>> >>
>> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
>> >>> >>            <property name="notificationDAO">
>> >>> >>            <osgi:reference
>> >>> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
>> >>> >>        </property>
>> >>> >>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>   <!-- Abstract service using the Geronimo Transaction Manager -->
>> >>> >>    <bean id="abstractService" abstract="true"
>> >>> >>
>> >>>
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>> >>> >>         <property name="transactionManager">
>> >>> >>            <osgi:reference
>> >>> >>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="notificationService"
>> >>> >>          parent="abstractService"
>> >>> >>
>> >>> >>
>> >>>
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>> >>> >>
>> >>> >>        <property name="target">
>> >>> >>            <ref bean="notificationServiceTarget" />
>> >>> >>        </property>
>> >>> >>
>> >>> >>        <property name="transactionAttributes">
>> >>> >>            <props>
>> >>> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
>> >>> >>            </props>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >> 4) Route
>> >>> >>
>> >>> >>    <bean id="myPolicy"
>> >>> class="org.apache.camel.processor.RedeliveryPolicy">
>> >>> >>        <property name="maximumRedeliveries" value="1"/>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="txErrorHandler"
>> >>> >> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>> >>> >>        <property name="springTransactionPolicy"
>> >>> >> ref="PROPAGATION_REQUIRED"/>
>> >>> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>    <bean id="PROPAGATION_REQUIRED"
>> >>> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >>> >>        <property name="transactionManager">
>> >>> >>            <osgi:reference
>> >>> >>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>        </property>
>> >>> >>    </bean>
>> >>> >>
>> >>> >>        <camel:route errorHandlerRef="txErrorHandler">
>> >>> >>            <camel:from ref="queueQuickFixInEndpoint" />
>> >>> >>            <camel:convertBodyTo type="quickfix.Message" />
>> >>> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>> >>> >>            <camel:bean ref="serviceHelper"
>> method="createNotification"
>> >>> />
>> >>> >>            <camel:bean ref="serviceHelper" method="generateError" />
>> >>> >>            <camel:to ref="directNotificationEndpoint" />
>> >>> >>        </camel:route>
>> >>> >>
>> >>> >> Any ideas are welcome
>> >>> >>
>> >>> >> Regards,
>> >>> >>
>> >>> >> Charles Moulliard
>> >>> >> Senior Enterprise Architect
>> >>> >> Apache Camel Committer
>> >>> >>
>> >>> >> *****************************
>> >>> >> blog : http://cmoulliard.blogspot.com
>> >>> >>
>> >>> >>
>> >>> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <
>> [hidden email]
>> >>> >wrote:
>> >>> >>
>> >>> >>> OK. I will try to create my own Hibernate JTATransaction manager as
>> the
>> >>> >>> existing try to perform a JNDI lookup to find the transaction
>> manager
>> >>> on
>> >>> >>> OSGI platform (inheritage from J2EE world)
>> >>> >>>
>> >>> >>>
>> >>> >>>
>> >>>
>> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>> >>> >>>
>> >>> >>>
>> >>> >>> Charles Moulliard
>> >>> >>> Senior Enterprise Architect
>> >>> >>> Apache Camel Committer
>> >>> >>>
>> >>> >>> *****************************
>> >>> >>> blog : http://cmoulliard.blogspot.com
>> >>> >>>
>> >>> >>>
>> >>> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]
>> >
>> >>> wrote:
>> >>> >>>
>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>> >>> [hidden email]>
>> >>> >>>> wrote:
>> >>> >>>> > queueQuickFixInEndpoint is a JMS queue.
>> >>> >>>> >
>> >>> >>>> > I will add the ref to the transacted and retest
>> >>> >>>> >
>> >>> >>>> > Question : I suppose that rollback will not occur if by example
>> JMS
>> >>> and
>> >>> >>>> DB
>> >>> >>>> > (=Hibernate) does not use the same TransactionManager and don't
>> use
>> >>> this
>> >>> >>>> > spring class together :
>> >>> >>>> > org.springframework.transaction.PlatformTransactionManager
>> >>> >>>> Yes they must be configured to use the same TX manager.
>> >>> >>>>
>> >>> >>>>
>> >>> >>>> >
>> >>> >>>> > Regards,
>> >>> >>>> >
>> >>> >>>> > Charles Moulliard
>> >>> >>>> > Senior Enterprise Architect
>> >>> >>>> > Apache Camel Committer
>> >>> >>>> >
>> >>> >>>> > *****************************
>> >>> >>>> > blog : http://cmoulliard.blogspot.com
>> >>> >>>> >
>> >>> >>>> >
>> >>> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <
>> [hidden email]>
>> >>> >>>> wrote:
>> >>> >>>> >
>> >>> >>>> >> Transacted also have a ref attribute
>> >>> >>>> >>
>> >>> >>>> >> <transacted ref="required"/>
>> >>> >>>> >>
>> >>> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
>> >>> >>>> >> You need to use a TX manager that can do both JMS and DB.
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
>> >>> [hidden email]
>> >>> >>>> >
>> >>> >>>> >> wrote:
>> >>> >>>> >> > I have been able to solve my problem by adding the following
>> bean
>> >>> >>>> >> definition
>> >>> >>>> >> > :
>> >>> >>>> >> >
>> >>> >>>> >> >    <bean id="required"
>> >>> >>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >>> >>>> >> >        <property name="transactionManager">
>> >>> >>>> >> >            <osgi:reference
>> >>> >>>> >> >
>> >>> >>>>
>> >>>
>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>> >>> >>>> >> >        </property>
>> >>> >>>> >> >    </bean>
>> >>> >>>> >> >
>> >>> >>>> >> > and in the route
>> >>> >>>> >> >
>> >>> >>>> >> >        <camel:route>
>> >>> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >>> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>> >>> >>>> >> >            <camel:transacted/>
>> >>> >>>> >> >            <camel:policy ref="required" />
>> >>> >>>> >> >            <camel:bean ref="serviceHelper"
>> >>> >>>> method="createNotification" />
>> >>> >>>> >> >            <camel:bean ref="serviceHelper"
>> method="generateError"
>> >>> />
>> >>> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
>> >>> >>>> >> >        </camel:route>
>> >>> >>>> >> >
>> >>> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
>> >>> records
>> >>> >>>> have
>> >>> >>>> >> been
>> >>> >>>> >> > created by the method createNotification when error has been
>> >>> raised
>> >>> >>>> by
>> >>> >>>> >> the
>> >>> >>>> >> > method generateError.
>> >>> >>>> >> >
>> >>> >>>> >> > What is missing ?
>> >>> >>>> >> >
>> >>> >>>> >> > Charles Moulliard
>> >>> >>>> >> > Senior Enterprise Architect
>> >>> >>>> >> > Apache Camel Committer
>> >>> >>>> >> >
>> >>> >>>> >> > *****************************
>> >>> >>>> >> > blog : http://cmoulliard.blogspot.com
>> >>> >>>> >> >
>> >>> >>>> >> >
>> >>> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>> >>> >>>> [hidden email]
>> >>> >>>> >> >wrote:
>> >>> >>>> >> >
>> >>> >>>> >> >> When I compare the example :
>> >>> JMSTransactionalClientRollbackTest.xml
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- START SNIPPET: e1 -->
>> >>> >>>> >> >>     <!-- setup JMS connection factory -->
>> >>> >>>> >> >>     <bean id="jmsConnectionFactory"
>> >>> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>> >>> >>>> >> >>         <property name="brokerURL"
>> >>> >>>> >> >>
>> >>> >>>>
>> >>>
>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
>> >>> >>>> >> >>     <bean id="jmsTransactionManager"
>> >>> >>>> >> >>
>> >>> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>> >>>> >> >>         <property name="connectionFactory"
>> >>> >>>> ref="jmsConnectionFactory"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- define our activemq component -->
>> >>> >>>> >> >>     <bean id="activemq"
>> >>> >>>> >> >>
>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >>> >>>> >> >>         <property name="connectionFactory"
>> >>> >>>> ref="jmsConnectionFactory"/>
>> >>> >>>> >> >>         <!-- define the jms consumer/producer as transacted
>> -->
>> >>> >>>> >> >>         <property name="transacted" value="true"/>
>> >>> >>>> >> >>         <!-- setup the transaction manager to use -->
>> >>> >>>> >> >>         <!-- if not provided then Camel will automatic use a
>> >>> >>>> >> >> JmsTransactionManager, however if you
>> >>> >>>> >> >>              for instance use a JTA transaction manager then
>> you
>> >>> >>>> must
>> >>> >>>> >> >> configure it -->
>> >>> >>>> >> >>         <property name="transactionManager"
>> >>> >>>> >> ref="jmsTransactionManager"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>     <!-- END SNIPPET: e1 -->
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- START SNIPPET: e2 -->
>> >>> >>>> >> >>     <camelContext xmlns="
>> http://camel.apache.org/schema/spring
>> >>> ">
>> >>> >>>> >> >>         <route>
>> >>> >>>> >> >>             <!-- 1: from the jms queue -->
>> >>> >>>> >> >>             <from uri="activemq:queue:okay"/>
>> >>> >>>> >> >>             <!-- 2: mark this route as transacted -->
>> >>> >>>> >> >>             <transacted/>
>> >>> >>>> >> >>             <!-- 3: call our business logic that is
>> myProcessor
>> >>> -->
>> >>> >>>> >> >>             <process ref="myProcessor"/>
>> >>> >>>> >> >>             <!-- 4: if success then send it to the mock -->
>> >>> >>>> >> >>             <to uri="mock:result"/>
>> >>> >>>> >> >>         </route>
>> >>> >>>> >> >>     </camelContext>
>> >>> >>>> >> >>
>> >>> >>>> >> >> with mine.
>> >>> >>>> >> >>
>> >>> >>>> >> >> What is different concerns the TransactionManager used.
>> >>> >>>> >> >>
>> >>> >>>> >> >> In the example, this is the Spring one:
>> >>> >>>> >> >>
>> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
>> >>> >>>> >> >>     <bean id="jmsTransactionManager"
>> >>> >>>> >> >>
>> >>> class="org.springframework.jms.connection.JmsTransactionManager">
>> >>> >>>> >> >>         <property name="connectionFactory"
>> >>> >>>> ref="jmsConnectionFactory"/>
>> >>> >>>> >> >>     </bean>
>> >>> >>>> >> >>
>> >>> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
>> >>> Transaction
>> >>> >>>> >> Manager
>> >>> >>>> >> >> bundle (which in fact uses spring Transaction manager :
>> >>> >>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>> >>> >>>> >> >>
>> >>> >>>> >> >> I suppose that in the example, the policy is defined by
>> default
>> >>> by
>> >>> >>>> >> spring
>> >>> >>>> >> >> when instantiating the class :
>> >>> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
>> >>> >>>> >> >>
>> >>> >>>> >> >> Is it possible to do the same using a JtaTransaction manager
>> ?
>> >>> >>>> >> >>
>> >>> >>>> >> >> Regards,
>> >>> >>>> >> >>
>> >>> >>>> >> >> Charles Moulliard
>> >>> >>>> >> >> Senior Enterprise Architect
>> >>> >>>> >> >> Apache Camel Committer
>> >>> >>>> >> >>
>> >>> >>>> >> >> *****************************
>> >>> >>>> >> >> blog : http://cmoulliard.blogspot.com
>> >>> >>>> >> >>
>> >>> >>>> >> >>
>> >>> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
>> >>> [hidden email]>
>> >>> >>>> >> wrote:
>> >>> >>>> >> >>
>> >>> >>>> >> >>> Hi
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
>> >>> >>>> >> >>>
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>> >>> >>>> [hidden email]
>> >>> >>>> >> >
>> >>> >>>> >> >>> wrote:
>> >>> >>>> >> >>> > Camel generates the following error with my route :
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > Route
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> >        <camel:route>
>> >>> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>> >>> >>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message"
>> />
>> >>> >>>> >> >>> >            <camel:transacted/>
>> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>> >>> >>>> >> method="createNotification"
>> >>> >>>> >> >>> />
>> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>> >>> method="generateError"
>> >>> >>>> />
>> >>> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>> >>> >>>> >> >>> >        </camel:route>
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > It seems that policy must be defined but in the example
>> here
>> >>> it
>> >>> >>>> is
>> >>> >>>> >> not
>> >>> >>>> >> >>> > mentioned :
>> >>> http://camel.apache.org/transactional-client.html
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > Error :
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
>> >>> ContextLoaderListener
>> >>> >>>> >> >>>    |
>> >>> >>>> >> >>> > BundleApplicationContextListener   50 | Application
>> context
>> >>> >>>> refresh
>> >>> >>>> >> >>> failed
>> >>> >>>> >> >>> >
>> >>> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>> >>> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>> >>> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
>> >>> >>>> >> >>> java.lang.IllegalArgumentException:
>> >>> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>> >>> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>> >>> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy
>> must be
>> >>> >>>> >> specified
>> >>> >>>> >> >>> on:
>> >>> >>>> >> >>> > Transacted[ref: null]
>> >>> >>>> >> >>> >    at
>> >>> >>>> >>
>> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >>
>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>> >>> >>>> >> >>> >    at
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >>
>> >>> >>>>
>> >>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>> >>> >>>> >> >>> > Charles Moulliard
>> >>> >>>> >> >>> > Senior Enterprise Architect
>> >>> >>>> >> >>> > Apache Camel Committer
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>> > *****************************
>> >>> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
>> >>> >>>> >> >>> >
>> >>> >>>> >> >>>
>> >>> >>>> >> >>>
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> --
>> >>> >>>> >> >>> Claus Ibsen
>> >>> >>>> >> >>> Apache Camel Committer
>> >>> >>>> >> >>>
>> >>> >>>> >> >>> Open Source Integration: http://fusesource.com
>> >>> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
>> >>> >>>> >> >>> Twitter: http://twitter.com/davsclaus
>> >>> >>>> >> >>>
>> >>> >>>> >> >>
>> >>> >>>> >> >>
>> >>> >>>> >> >
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >>
>> >>> >>>> >> --
>> >>> >>>> >> Claus Ibsen
>> >>> >>>> >> Apache Camel Committer
>> >>> >>>> >>
>> >>> >>>> >> Open Source Integration: http://fusesource.com
>> >>> >>>> >> Blog: http://davsclaus.blogspot.com/
>> >>> >>>> >> Twitter: http://twitter.com/davsclaus
>> >>> >>>> >>
>> >>> >>>> >
>> >>> >>>>
>> >>> >>>>
>> >>> >>>>
>> >>> >>>> --
>> >>> >>>> Claus Ibsen
>> >>> >>>> Apache Camel Committer
>> >>> >>>>
>> >>> >>>> Open Source Integration: http://fusesource.com
>> >>> >>>> Blog: http://davsclaus.blogspot.com/
>> >>> >>>> Twitter: http://twitter.com/davsclaus
>> >>> >>>>
>> >>> >>>
>> >>> >>>
>> >>> >>
>> >>> >
>> >>> >
>> >>> >
>> >>> > --
>> >>> > Claus Ibsen
>> >>> > Apache Camel Committer
>> >>> >
>> >>> > Open Source Integration: http://fusesource.com
>> >>> > Blog: http://davsclaus.blogspot.com/
>> >>> > Twitter: http://twitter.com/davsclaus
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Claus Ibsen
>> >>> Apache Camel Committer
>> >>>
>> >>> Open Source Integration: http://fusesource.com
>> >>> Blog: http://davsclaus.blogspot.com/
>> >>> Twitter: http://twitter.com/davsclaus
>> >>>
>> >>
>> >
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> > ------------------------
>> > Open Source SOA
>> > http://fusesource.com
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Claus Ibsen-2
On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<[hidden email]> wrote:
> If the message is redelivered, this means there is a rollback.
> I guess the problem is that your DB is not enlisted in the transaction.
> However, if you don't want to use XA and two phase commit, you should
> try to perform the database step as late as possible so that there is very few
> chances that anything wrong happen after the data has been written to the DB.
> Btw, in your route, I don't see at which step the message is written
> to the DB ... ?

He uses 2 independent DB calls and uses a JMS TX manager. Then its
bound not to be enlisted in the same TX manager.
So as G. Nodet said try to combine your DB calls into a single
invocation, eg you might need to start / stop a local DB transaction
yourself using Hibernate and/or JPA.



>
> On Fri, Jul 3, 2009 at 15:26, Charles Moulliard<[hidden email]> wrote:
>> I have created a small route without JMS stuff.
>>
>> Here is the route :
>>
>>        <camel:route>
>>            <camel:from ref="fileClientEndpoint" />
>>
>>            <camel:setHeader headerName="origin">
>>                <camel:constant>file</camel:constant>
>>            </camel:setHeader>
>>            <camel:setHeader headerName="messageType">
>>                <camel:constant>OINP</camel:constant>
>>            </camel:setHeader>
>>            <camel:convertBodyTo type="java.lang.String"/>
>>            <camel:to ref="directRequestEndpoint" />
>>        </camel:route>
>>
>>        <camel:route>
>>            <camel:from ref="directRequestEndpoint" />
>>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>>            <!-- Call the requestService to save the request -->
>>            <camel:bean ref="serviceHelper" method="createRequest"/>
>>            <camel:bean ref="serviceHelper" method="generateError" />
>>            <camel:to uri="direct:testTx"/>
>>        </camel:route>
>>
>> Unfortunately when a throw error is generated in bean called "generateError"
>>
>>    public void generateError() {
>>            throw new IllegalArgumentException("Generate error to test
>> rollback");
>>    }
>>
>> records are committed in the DB and not rollbacked
>>
>>
>> I see that when the error is throw the message is redelivered a second time
>> as this parameter has been defined in the ActiveMq
>>
>>    <bean id="x3sPolicy" class="org.apache.activemq.RedeliveryPolicy">
>> *        <property name="maximumRedeliveries" value="1"/>*
>>    </bean>
>>
>>    <bean id="activemqConnectionFactory"
>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>        <property name="brokerURL" value="tcp://localhost:61616" />
>>        <property name="redeliveryPolicy" ref="x3sPolicy"/>
>>    </bean>
>>
>> Question :  Why policy defined in the ActiveMq is taken into account here ?
>> Why the rollback does not occur ?
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Fri, Jul 3, 2009 at 12:28 PM, Claus Ibsen <[hidden email]> wrote:
>>
>>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<[hidden email]> wrote:
>>> > In this case, you should not use transactions for the DB at all, but
>>> > if any error occurs while saving the data, an exception should be
>>> > thrown and should rollback the transaction for the JMS layer.
>>> Yeah that would be perfect unless he does some work afterwards the DB
>>> and that throws an Exception.
>>> Then the DB layer have already committed.
>>>
>>> So trying to avoid doing work after the DB layer would help.
>>>
>>>
>>> Is this not possible?
>>> But he is doing JPA/Hibernte stuff so he could grab the "session" and
>>> invoke a rollback manually in case errors happen afterwards.
>>>
>>>
>>>
>>>
>>> >
>>> > On Fri, Jul 3, 2009 at 10:48, Charles Moulliard<[hidden email]>
>>> wrote:
>>> >> Claus,
>>> >>
>>> >> I don't want at all to use XA transaction. Correct me if I'm wrong but
>>> the
>>> >> example of the documentation (Camel 2.0 - JMS Sample - part Spring XML)
>>> does
>>> >> not use at all a XA driver and the message will not be removed from the
>>> >> queue if a rollback occurs in the bean MyProcessor ?
>>> >>
>>> >> My concern is to avoid to lost messages from a file, queues if something
>>> >> happen in one of the services called where by example we have to save
>>> data
>>> >> in a DB or generate a report for a client. If such errors occur, then we
>>> >> have to investigate why can't save data in DB (maybe related to a
>>> connection
>>> >> issue, DB shutdown, ...) or generates files (maybe due to disk full,
>>> access
>>> >> right, ....). Sometimes, this is related to conditions out of the
>>> control of
>>> >> our application but sometimes no, then we have to correct the error and
>>> >> install a new version of the code. After the restart of the application
>>> and
>>> >> recovery of messages (persisted in the case of activemq), messages will
>>> be
>>> >> reprocessed.
>>> >>
>>> >> Regards,
>>> >>
>>> >> Charles Moulliard
>>> >> Senior Enterprise Architect
>>> >> Apache Camel Committer
>>> >>
>>> >> *****************************
>>> >> blog : http://cmoulliard.blogspot.com
>>> >>
>>> >>
>>> >> On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]>
>>> wrote:
>>> >>
>>> >>> And reconsider if you need XA at all. Its slow and hard to get setup.
>>> >>>
>>> >>> Try to let the DB be the last stuff you do and afterwards send the
>>> >>> message to another queue for further processing in a 2nd route.
>>> >>> If that is possible in your use-case.
>>> >>>
>>> >>>
>>> >>> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]>
>>> wrote:
>>> >>> > Hi
>>> >>> >
>>> >>> > Get it working outside OSGi, eg in a small unit test thats easy to
>>> run
>>> >>> > and test from within your IDE.
>>> >>> > Google for JMS + hibernate + TX + XA to find some samples that work.
>>> >>> >
>>> >>> > And since you use JMS + DB in the same TX you need to use XA db
>>> driver.
>>> >>> >
>>> >>> > It can be a painful to get setup
>>> >>> >
>>> >>>
>>> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
>>> >>> >
>>> >>> > And you need an XA TX manager such as JOTM
>>> >>> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
>>> >>> >
>>> >>> > In j2ee land there was a JTA with the container that could do it. But
>>> >>> > in your OSGi container I do not know if it provides one out of the
>>> >>> > box.
>>> >>> >
>>> >>> >
>>> >>> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<
>>> [hidden email]>
>>> >>> wrote:
>>> >>> >> I'm still fighting against Spring config or Camel because Rollback
>>> does
>>> >>> not
>>> >>> >> occur. I have been able to configure Hibernate to use the same
>>> >>> >> TransactionManager as the one used by JMS
>>> >>> >>
>>> >>> >> Here is the different part of the config. I don't know where the
>>> issue
>>> >>> could
>>> >>> >> be !
>>> >>> >>
>>> >>> >> 1) ActiveMQ
>>> >>> >>
>>> >>> >> ...
>>> >>> >>
>>> >>> >>    <bean id="activemqConnectionFactory"
>>> >>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>>> >>> >>        <property name="brokerURL" value="tcp://localhost:61616" />
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>    <bean id="pooledConnectionFactory"
>>> >>> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
>>> >>> >>        <property name="maxConnections" value="8" />
>>> >>> >>        <property name="maximumActive" value="500" />
>>> >>> >>        <property name="transactionManager" ref="transactionManager"
>>> />
>>> >>> >>        <property name="connectionFactory"
>>> >>> ref="activemqConnectionFactory"
>>> >>> >> />
>>> >>> >>        <property name="resourceName" value="activemq.default" />
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>    <bean id="resourceManager"
>>> >>> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
>>> >>> >> init-method="recoverResource">
>>> >>> >>          <property name="transactionManager"
>>> ref="transactionManager" />
>>> >>> >>          <property name="connectionFactory"
>>> >>> ref="activemqConnectionFactory"
>>> >>> >> />
>>> >>> >>          <property name="resourceName" value="activemq.default" />
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>    <osgi:reference id="transactionManager"
>>> >>> >> interface="javax.transaction.TransactionManager" /> // This OSGI
>>> service
>>> >>> is
>>> >>> >> published by Geronimo Transaction bundle
>>> >>> >>
>>> >>> >>    <osgi:service ref="pooledConnectionFactory">
>>> >>> >>        <osgi:interfaces>
>>> >>> >>            <value>javax.jms.ConnectionFactory</value>
>>> >>> >>        </osgi:interfaces>
>>> >>> >>        <osgi:service-properties>
>>> >>> >>            <entry key="name" value="default"/>
>>> >>> >>        </osgi:service-properties>
>>> >>> >>    </osgi:service>
>>> >>> >>
>>> >>> >> 2) Camel ActiveMQComponent
>>> >>> >>
>>> >>> >>    <bean id="active-mq"
>>> >>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>> >>> >>        <property name="transacted" value="true"/>
>>> >>> >>        <property name="connectionFactory">
>>> >>> >>            <osgi:reference interface="javax.jms.ConnectionFactory"/>
>>> //
>>> >>> >> OSGI service is published by ActiveMQ service
>>> >>> >>        </property>
>>> >>> >>        <property name="transactionManager">
>>> >>> >>            <osgi:reference
>>> >>> >>
>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>> >>        </property>
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >> 2) Hibernate - DAO
>>> >>> >>
>>> >>> >>    <bean id="sessionFactory"
>>> >>> >> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>>> >>> >>
>>> >>> >>        <property name="mappingLocations">
>>> >>> >>            <list>
>>> >>> >>
>>> >>> >>
>>> >>>
>>> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
>>> >>> >>            </list>
>>> >>> >>        </property>
>>> >>> >>
>>> >>> >>        <property name="hibernateProperties">
>>> >>> >>            <props>
>>> >>> >>                <prop
>>> >>> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>>> >>> >>                <prop key="hibernate.show_sql">true</prop>
>>> >>> >>                <prop key="hibernate.format_sql">true</prop>
>>> >>> >>                <prop
>>> >>> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>>> >>> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
>>> >>> >>                <prop
>>> >>> >>
>>> >>>
>>> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
>>> >>> >>                <prop
>>> >>> >>
>>> >>>
>>> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
>>> >>> >>            </props>
>>> >>> >>        </property>
>>> >>> >>        <property name="dataSource">
>>> >>> >>            <ref bean="dataSource" />
>>> >>> >>        </property>
>>> >>> >>
>>> >>> >> Remark : To avoid the JNDI lookup issue, we use
>>> springTransactionFactory
>>> >>> as
>>> >>> >> the TransactionFactory for Hibernate (
>>> >>> >> http://forum.springsource.org/showthread.php?p=215720)
>>> >>> >>
>>> >>> >> 3) Service layer
>>> >>> >>
>>> >>> >> Here is the definition of the service used from Camel route :
>>> >>> >>
>>> >>> >>    <bean id="notificationServiceTarget"
>>> >>> >>
>>> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
>>> >>> >>            <property name="notificationDAO">
>>> >>> >>            <osgi:reference
>>> >>> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
>>> >>> >>        </property>
>>> >>> >>
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>   <!-- Abstract service using the Geronimo Transaction Manager -->
>>> >>> >>    <bean id="abstractService" abstract="true"
>>> >>> >>
>>> >>>
>>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>>> >>> >>         <property name="transactionManager">
>>> >>> >>            <osgi:reference
>>> >>> >>
>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>> >>        </property>
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>    <bean id="notificationService"
>>> >>> >>          parent="abstractService"
>>> >>> >>
>>> >>> >>
>>> >>>
>>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>>> >>> >>
>>> >>> >>        <property name="target">
>>> >>> >>            <ref bean="notificationServiceTarget" />
>>> >>> >>        </property>
>>> >>> >>
>>> >>> >>        <property name="transactionAttributes">
>>> >>> >>            <props>
>>> >>> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
>>> >>> >>            </props>
>>> >>> >>        </property>
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >> 4) Route
>>> >>> >>
>>> >>> >>    <bean id="myPolicy"
>>> >>> class="org.apache.camel.processor.RedeliveryPolicy">
>>> >>> >>        <property name="maximumRedeliveries" value="1"/>
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>    <bean id="txErrorHandler"
>>> >>> >> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>>> >>> >>        <property name="springTransactionPolicy"
>>> >>> >> ref="PROPAGATION_REQUIRED"/>
>>> >>> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>    <bean id="PROPAGATION_REQUIRED"
>>> >>> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>> >>> >>        <property name="transactionManager">
>>> >>> >>            <osgi:reference
>>> >>> >>
>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>> >>        </property>
>>> >>> >>    </bean>
>>> >>> >>
>>> >>> >>        <camel:route errorHandlerRef="txErrorHandler">
>>> >>> >>            <camel:from ref="queueQuickFixInEndpoint" />
>>> >>> >>            <camel:convertBodyTo type="quickfix.Message" />
>>> >>> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
>>> >>> >>            <camel:bean ref="serviceHelper"
>>> method="createNotification"
>>> >>> />
>>> >>> >>            <camel:bean ref="serviceHelper" method="generateError" />
>>> >>> >>            <camel:to ref="directNotificationEndpoint" />
>>> >>> >>        </camel:route>
>>> >>> >>
>>> >>> >> Any ideas are welcome
>>> >>> >>
>>> >>> >> Regards,
>>> >>> >>
>>> >>> >> Charles Moulliard
>>> >>> >> Senior Enterprise Architect
>>> >>> >> Apache Camel Committer
>>> >>> >>
>>> >>> >> *****************************
>>> >>> >> blog : http://cmoulliard.blogspot.com
>>> >>> >>
>>> >>> >>
>>> >>> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <
>>> [hidden email]
>>> >>> >wrote:
>>> >>> >>
>>> >>> >>> OK. I will try to create my own Hibernate JTATransaction manager as
>>> the
>>> >>> >>> existing try to perform a JNDI lookup to find the transaction
>>> manager
>>> >>> on
>>> >>> >>> OSGI platform (inheritage from J2EE world)
>>> >>> >>>
>>> >>> >>>
>>> >>> >>>
>>> >>>
>>> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
>>> >>> >>>
>>> >>> >>>
>>> >>> >>> Charles Moulliard
>>> >>> >>> Senior Enterprise Architect
>>> >>> >>> Apache Camel Committer
>>> >>> >>>
>>> >>> >>> *****************************
>>> >>> >>> blog : http://cmoulliard.blogspot.com
>>> >>> >>>
>>> >>> >>>
>>> >>> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <[hidden email]
>>> >
>>> >>> wrote:
>>> >>> >>>
>>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>>> >>> [hidden email]>
>>> >>> >>>> wrote:
>>> >>> >>>> > queueQuickFixInEndpoint is a JMS queue.
>>> >>> >>>> >
>>> >>> >>>> > I will add the ref to the transacted and retest
>>> >>> >>>> >
>>> >>> >>>> > Question : I suppose that rollback will not occur if by example
>>> JMS
>>> >>> and
>>> >>> >>>> DB
>>> >>> >>>> > (=Hibernate) does not use the same TransactionManager and don't
>>> use
>>> >>> this
>>> >>> >>>> > spring class together :
>>> >>> >>>> > org.springframework.transaction.PlatformTransactionManager
>>> >>> >>>> Yes they must be configured to use the same TX manager.
>>> >>> >>>>
>>> >>> >>>>
>>> >>> >>>> >
>>> >>> >>>> > Regards,
>>> >>> >>>> >
>>> >>> >>>> > Charles Moulliard
>>> >>> >>>> > Senior Enterprise Architect
>>> >>> >>>> > Apache Camel Committer
>>> >>> >>>> >
>>> >>> >>>> > *****************************
>>> >>> >>>> > blog : http://cmoulliard.blogspot.com
>>> >>> >>>> >
>>> >>> >>>> >
>>> >>> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <
>>> [hidden email]>
>>> >>> >>>> wrote:
>>> >>> >>>> >
>>> >>> >>>> >> Transacted also have a ref attribute
>>> >>> >>>> >>
>>> >>> >>>> >> <transacted ref="required"/>
>>> >>> >>>> >>
>>> >>> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
>>> >>> >>>> >> You need to use a TX manager that can do both JMS and DB.
>>> >>> >>>> >>
>>> >>> >>>> >>
>>> >>> >>>> >>
>>> >>> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
>>> >>> [hidden email]
>>> >>> >>>> >
>>> >>> >>>> >> wrote:
>>> >>> >>>> >> > I have been able to solve my problem by adding the following
>>> bean
>>> >>> >>>> >> definition
>>> >>> >>>> >> > :
>>> >>> >>>> >> >
>>> >>> >>>> >> >    <bean id="required"
>>> >>> >>>> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>> >>> >>>> >> >        <property name="transactionManager">
>>> >>> >>>> >> >            <osgi:reference
>>> >>> >>>> >> >
>>> >>> >>>>
>>> >>>
>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>> >>> >>>> >> >        </property>
>>> >>> >>>> >> >    </bean>
>>> >>> >>>> >> >
>>> >>> >>>> >> > and in the route
>>> >>> >>>> >> >
>>> >>> >>>> >> >        <camel:route>
>>> >>> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
>>> >>> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
>>> >>> >>>> >> >            <camel:transacted/>
>>> >>> >>>> >> >            <camel:policy ref="required" />
>>> >>> >>>> >> >            <camel:bean ref="serviceHelper"
>>> >>> >>>> method="createNotification" />
>>> >>> >>>> >> >            <camel:bean ref="serviceHelper"
>>> method="generateError"
>>> >>> />
>>> >>> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
>>> >>> >>>> >> >        </camel:route>
>>> >>> >>>> >> >
>>> >>> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
>>> >>> records
>>> >>> >>>> have
>>> >>> >>>> >> been
>>> >>> >>>> >> > created by the method createNotification when error has been
>>> >>> raised
>>> >>> >>>> by
>>> >>> >>>> >> the
>>> >>> >>>> >> > method generateError.
>>> >>> >>>> >> >
>>> >>> >>>> >> > What is missing ?
>>> >>> >>>> >> >
>>> >>> >>>> >> > Charles Moulliard
>>> >>> >>>> >> > Senior Enterprise Architect
>>> >>> >>>> >> > Apache Camel Committer
>>> >>> >>>> >> >
>>> >>> >>>> >> > *****************************
>>> >>> >>>> >> > blog : http://cmoulliard.blogspot.com
>>> >>> >>>> >> >
>>> >>> >>>> >> >
>>> >>> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
>>> >>> >>>> [hidden email]
>>> >>> >>>> >> >wrote:
>>> >>> >>>> >> >
>>> >>> >>>> >> >> When I compare the example :
>>> >>> JMSTransactionalClientRollbackTest.xml
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>     <!-- START SNIPPET: e1 -->
>>> >>> >>>> >> >>     <!-- setup JMS connection factory -->
>>> >>> >>>> >> >>     <bean id="jmsConnectionFactory"
>>> >>> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
>>> >>> >>>> >> >>         <property name="brokerURL"
>>> >>> >>>> >> >>
>>> >>> >>>>
>>> >>>
>>> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
>>> >>> >>>> >> >>     </bean>
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
>>> >>> >>>> >> >>     <bean id="jmsTransactionManager"
>>> >>> >>>> >> >>
>>> >>> class="org.springframework.jms.connection.JmsTransactionManager">
>>> >>> >>>> >> >>         <property name="connectionFactory"
>>> >>> >>>> ref="jmsConnectionFactory"/>
>>> >>> >>>> >> >>     </bean>
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>     <!-- define our activemq component -->
>>> >>> >>>> >> >>     <bean id="activemq"
>>> >>> >>>> >> >>
>>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>> >>> >>>> >> >>         <property name="connectionFactory"
>>> >>> >>>> ref="jmsConnectionFactory"/>
>>> >>> >>>> >> >>         <!-- define the jms consumer/producer as transacted
>>> -->
>>> >>> >>>> >> >>         <property name="transacted" value="true"/>
>>> >>> >>>> >> >>         <!-- setup the transaction manager to use -->
>>> >>> >>>> >> >>         <!-- if not provided then Camel will automatic use a
>>> >>> >>>> >> >> JmsTransactionManager, however if you
>>> >>> >>>> >> >>              for instance use a JTA transaction manager then
>>> you
>>> >>> >>>> must
>>> >>> >>>> >> >> configure it -->
>>> >>> >>>> >> >>         <property name="transactionManager"
>>> >>> >>>> >> ref="jmsTransactionManager"/>
>>> >>> >>>> >> >>     </bean>
>>> >>> >>>> >> >>     <!-- END SNIPPET: e1 -->
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>     <!-- START SNIPPET: e2 -->
>>> >>> >>>> >> >>     <camelContext xmlns="
>>> http://camel.apache.org/schema/spring
>>> >>> ">
>>> >>> >>>> >> >>         <route>
>>> >>> >>>> >> >>             <!-- 1: from the jms queue -->
>>> >>> >>>> >> >>             <from uri="activemq:queue:okay"/>
>>> >>> >>>> >> >>             <!-- 2: mark this route as transacted -->
>>> >>> >>>> >> >>             <transacted/>
>>> >>> >>>> >> >>             <!-- 3: call our business logic that is
>>> myProcessor
>>> >>> -->
>>> >>> >>>> >> >>             <process ref="myProcessor"/>
>>> >>> >>>> >> >>             <!-- 4: if success then send it to the mock -->
>>> >>> >>>> >> >>             <to uri="mock:result"/>
>>> >>> >>>> >> >>         </route>
>>> >>> >>>> >> >>     </camelContext>
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> with mine.
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> What is different concerns the TransactionManager used.
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> In the example, this is the Spring one:
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
>>> >>> >>>> >> >>     <bean id="jmsTransactionManager"
>>> >>> >>>> >> >>
>>> >>> class="org.springframework.jms.connection.JmsTransactionManager">
>>> >>> >>>> >> >>         <property name="connectionFactory"
>>> >>> >>>> ref="jmsConnectionFactory"/>
>>> >>> >>>> >> >>     </bean>
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
>>> >>> Transaction
>>> >>> >>>> >> Manager
>>> >>> >>>> >> >> bundle (which in fact uses spring Transaction manager :
>>> >>> >>>> >> >> org.springframework.transaction.jta.JtaTransactionManager;)
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> I suppose that in the example, the policy is defined by
>>> default
>>> >>> by
>>> >>> >>>> >> spring
>>> >>> >>>> >> >> when instantiating the class :
>>> >>> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> Is it possible to do the same using a JtaTransaction manager
>>> ?
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> Regards,
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> Charles Moulliard
>>> >>> >>>> >> >> Senior Enterprise Architect
>>> >>> >>>> >> >> Apache Camel Committer
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> *****************************
>>> >>> >>>> >> >> blog : http://cmoulliard.blogspot.com
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>
>>> >>> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
>>> >>> [hidden email]>
>>> >>> >>>> >> wrote:
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>> Hi
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>>> >>> >>>> [hidden email]
>>> >>> >>>> >> >
>>> >>> >>>> >> >>> wrote:
>>> >>> >>>> >> >>> > Camel generates the following error with my route :
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>> > Route
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>> >        <camel:route>
>>> >>> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint" />
>>> >>> >>>> >> >>> >            <camel:convertBodyTo type="quickfix.Message"
>>> />
>>> >>> >>>> >> >>> >            <camel:transacted/>
>>> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>>> >>> >>>> >> method="createNotification"
>>> >>> >>>> >> >>> />
>>> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
>>> >>> method="generateError"
>>> >>> >>>> />
>>> >>> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint" />
>>> >>> >>>> >> >>> >        </camel:route>
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>> > It seems that policy must be defined but in the example
>>> here
>>> >>> it
>>> >>> >>>> is
>>> >>> >>>> >> not
>>> >>> >>>> >> >>> > mentioned :
>>> >>> http://camel.apache.org/transactional-client.html
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>> > Error :
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
>>> >>> ContextLoaderListener
>>> >>> >>>> >> >>>    |
>>> >>> >>>> >> >>> > BundleApplicationContextListener   50 | Application
>>> context
>>> >>> >>>> refresh
>>> >>> >>>> >> >>> failed
>>> >>> >>>> >> >>> >
>>> >>> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
>>> >>> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
>>> >>> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
>>> >>> >>>> >> >>> java.lang.IllegalArgumentException:
>>> >>> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>>> >>> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
>>> >>> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy
>>> must be
>>> >>> >>>> >> specified
>>> >>> >>>> >> >>> on:
>>> >>> >>>> >> >>> > Transacted[ref: null]
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >>
>>> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >>
>>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
>>> >>> >>>> >> >>> >    at
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >>
>>> >>> >>>>
>>> >>>
>>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
>>> >>> >>>> >> >>> > Charles Moulliard
>>> >>> >>>> >> >>> > Senior Enterprise Architect
>>> >>> >>>> >> >>> > Apache Camel Committer
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>> > *****************************
>>> >>> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
>>> >>> >>>> >> >>> >
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>> --
>>> >>> >>>> >> >>> Claus Ibsen
>>> >>> >>>> >> >>> Apache Camel Committer
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>> Open Source Integration: http://fusesource.com
>>> >>> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
>>> >>> >>>> >> >>> Twitter: http://twitter.com/davsclaus
>>> >>> >>>> >> >>>
>>> >>> >>>> >> >>
>>> >>> >>>> >> >>
>>> >>> >>>> >> >
>>> >>> >>>> >>
>>> >>> >>>> >>
>>> >>> >>>> >>
>>> >>> >>>> >> --
>>> >>> >>>> >> Claus Ibsen
>>> >>> >>>> >> Apache Camel Committer
>>> >>> >>>> >>
>>> >>> >>>> >> Open Source Integration: http://fusesource.com
>>> >>> >>>> >> Blog: http://davsclaus.blogspot.com/
>>> >>> >>>> >> Twitter: http://twitter.com/davsclaus
>>> >>> >>>> >>
>>> >>> >>>> >
>>> >>> >>>>
>>> >>> >>>>
>>> >>> >>>>
>>> >>> >>>> --
>>> >>> >>>> Claus Ibsen
>>> >>> >>>> Apache Camel Committer
>>> >>> >>>>
>>> >>> >>>> Open Source Integration: http://fusesource.com
>>> >>> >>>> Blog: http://davsclaus.blogspot.com/
>>> >>> >>>> Twitter: http://twitter.com/davsclaus
>>> >>> >>>>
>>> >>> >>>
>>> >>> >>>
>>> >>> >>
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> > --
>>> >>> > Claus Ibsen
>>> >>> > Apache Camel Committer
>>> >>> >
>>> >>> > Open Source Integration: http://fusesource.com
>>> >>> > Blog: http://davsclaus.blogspot.com/
>>> >>> > Twitter: http://twitter.com/davsclaus
>>> >>> >
>>> >>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> Claus Ibsen
>>> >>> Apache Camel Committer
>>> >>>
>>> >>> Open Source Integration: http://fusesource.com
>>> >>> Blog: http://davsclaus.blogspot.com/
>>> >>> Twitter: http://twitter.com/davsclaus
>>> >>>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Cheers,
>>> > Guillaume Nodet
>>> > ------------------------
>>> > Blog: http://gnodet.blogspot.com/
>>> > ------------------------
>>> > Open Source SOA
>>> > http://fusesource.com
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error using Transacted with Camel 2.0

Charles Moulliard
In reply to this post by Guillaume Nodet
After verification, it appears that the message has not been redelivered.
So, only one record is created in the DB.

What I try to do is based on the camel test example :
apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java
where error is generated in the second bean called and rollback is done on
records created by bean 1.

The message is saved in the DB when the following bean is called :
<camel:bean ref="serviceHelper" method="createRequest"/>
CreateRequest do the following :

        // Instantiate the Request class
        Request request = new Request();

        // Add the CSV records to the body field, ...
        request.setMessageContent(body.getBytes());
        request.setFileName(fileName);
        request.setRequestType(messageType);

        // Set the status
        request.setRequestStatus(ProcessingStatusType.NEW.getValue());

        // Save the request in the DB
        this.requestService.saveRequest(request);

The service requestService is injected by Spring and is transactional :

    <bean id="requestServiceTarget"
class="com.xpectis.x3s.platform.service.impl.RequestServiceImpl">
        <property name="requestDAO">
            <osgi:reference
interface="com.xpectis.x3s.platform.dao.RequestDAO"/>
        </property>
    </bean>

    <bean id="abstractService" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
         <property name="transactionManager">
            <osgi:reference
interface="org.springframework.transaction.PlatformTransactionManager"/>
        </property>
    </bean>

    <bean id="requestService"
          parent="abstractService"

class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

        <property name="target">
            <ref bean="requestServiceTarget" />
        </property>

        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet <[hidden email]> wrote:

> If the message is redelivered, this means there is a rollback.
> I guess the problem is that your DB is not enlisted in the transaction.
> However, if you don't want to use XA and two phase commit, you should
> try to perform the database step as late as possible so that there is very
> few
> chances that anything wrong happen after the data has been written to the
> DB.
> Btw, in your route, I don't see at which step the message is written
> to the DB ... ?
>
> On Fri, Jul 3, 2009 at 15:26, Charles Moulliard<[hidden email]>
> wrote:
> > I have created a small route without JMS stuff.
> >
> > Here is the route :
> >
> >        <camel:route>
> >            <camel:from ref="fileClientEndpoint" />
> >
> >            <camel:setHeader headerName="origin">
> >                <camel:constant>file</camel:constant>
> >            </camel:setHeader>
> >            <camel:setHeader headerName="messageType">
> >                <camel:constant>OINP</camel:constant>
> >            </camel:setHeader>
> >            <camel:convertBodyTo type="java.lang.String"/>
> >            <camel:to ref="directRequestEndpoint" />
> >        </camel:route>
> >
> >        <camel:route>
> >            <camel:from ref="directRequestEndpoint" />
> >            <camel:transacted ref="PROPAGATION_REQUIRED"/>
> >            <!-- Call the requestService to save the request -->
> >            <camel:bean ref="serviceHelper" method="createRequest"/>
> >            <camel:bean ref="serviceHelper" method="generateError" />
> >            <camel:to uri="direct:testTx"/>
> >        </camel:route>
> >
> > Unfortunately when a throw error is generated in bean called
> "generateError"
> >
> >    public void generateError() {
> >            throw new IllegalArgumentException("Generate error to test
> > rollback");
> >    }
> >
> > records are committed in the DB and not rollbacked
> >
> >
> > I see that when the error is throw the message is redelivered a second
> time
> > as this parameter has been defined in the ActiveMq
> >
> >    <bean id="x3sPolicy" class="org.apache.activemq.RedeliveryPolicy">
> > *        <property name="maximumRedeliveries" value="1"/>*
> >    </bean>
> >
> >    <bean id="activemqConnectionFactory"
> > class="org.apache.activemq.ActiveMQConnectionFactory">
> >        <property name="brokerURL" value="tcp://localhost:61616" />
> >        <property name="redeliveryPolicy" ref="x3sPolicy"/>
> >    </bean>
> >
> > Question :  Why policy defined in the ActiveMq is taken into account here
> ?
> > Why the rollback does not occur ?
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jul 3, 2009 at 12:28 PM, Claus Ibsen <[hidden email]>
> wrote:
> >
> >> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<[hidden email]>
> wrote:
> >> > In this case, you should not use transactions for the DB at all, but
> >> > if any error occurs while saving the data, an exception should be
> >> > thrown and should rollback the transaction for the JMS layer.
> >> Yeah that would be perfect unless he does some work afterwards the DB
> >> and that throws an Exception.
> >> Then the DB layer have already committed.
> >>
> >> So trying to avoid doing work after the DB layer would help.
> >>
> >>
> >> Is this not possible?
> >> But he is doing JPA/Hibernte stuff so he could grab the "session" and
> >> invoke a rollback manually in case errors happen afterwards.
> >>
> >>
> >>
> >>
> >> >
> >> > On Fri, Jul 3, 2009 at 10:48, Charles Moulliard<[hidden email]>
> >> wrote:
> >> >> Claus,
> >> >>
> >> >> I don't want at all to use XA transaction. Correct me if I'm wrong
> but
> >> the
> >> >> example of the documentation (Camel 2.0 - JMS Sample - part Spring
> XML)
> >> does
> >> >> not use at all a XA driver and the message will not be removed from
> the
> >> >> queue if a rollback occurs in the bean MyProcessor ?
> >> >>
> >> >> My concern is to avoid to lost messages from a file, queues if
> something
> >> >> happen in one of the services called where by example we have to save
> >> data
> >> >> in a DB or generate a report for a client. If such errors occur, then
> we
> >> >> have to investigate why can't save data in DB (maybe related to a
> >> connection
> >> >> issue, DB shutdown, ...) or generates files (maybe due to disk full,
> >> access
> >> >> right, ....). Sometimes, this is related to conditions out of the
> >> control of
> >> >> our application but sometimes no, then we have to correct the error
> and
> >> >> install a new version of the code. After the restart of the
> application
> >> and
> >> >> recovery of messages (persisted in the case of activemq), messages
> will
> >> be
> >> >> reprocessed.
> >> >>
> >> >> Regards,
> >> >>
> >> >> Charles Moulliard
> >> >> Senior Enterprise Architect
> >> >> Apache Camel Committer
> >> >>
> >> >> *****************************
> >> >> blog : http://cmoulliard.blogspot.com
> >> >>
> >> >>
> >> >> On Fri, Jul 3, 2009 at 10:26 AM, Claus Ibsen <[hidden email]>
> >> wrote:
> >> >>
> >> >>> And reconsider if you need XA at all. Its slow and hard to get
> setup.
> >> >>>
> >> >>> Try to let the DB be the last stuff you do and afterwards send the
> >> >>> message to another queue for further processing in a 2nd route.
> >> >>> If that is possible in your use-case.
> >> >>>
> >> >>>
> >> >>> On Fri, Jul 3, 2009 at 10:25 AM, Claus Ibsen<[hidden email]>
> >> wrote:
> >> >>> > Hi
> >> >>> >
> >> >>> > Get it working outside OSGi, eg in a small unit test thats easy to
> >> run
> >> >>> > and test from within your IDE.
> >> >>> > Google for JMS + hibernate + TX + XA to find some samples that
> work.
> >> >>> >
> >> >>> > And since you use JMS + DB in the same TX you need to use XA db
> >> driver.
> >> >>> >
> >> >>> > It can be a painful to get setup
> >> >>> >
> >> >>>
> >>
> http://coffeedrivenjava.blogspot.com/2006/08/distributed-xa-transactions-w-hibernate.html
> >> >>> >
> >> >>> > And you need an XA TX manager such as JOTM
> >> >>> > http://jotm.ow2.org/xwiki/bin/view/Main/WebHome
> >> >>> >
> >> >>> > In j2ee land there was a JTA with the container that could do it.
> But
> >> >>> > in your OSGi container I do not know if it provides one out of the
> >> >>> > box.
> >> >>> >
> >> >>> >
> >> >>> > On Fri, Jul 3, 2009 at 10:09 AM, Charles Moulliard<
> >> [hidden email]>
> >> >>> wrote:
> >> >>> >> I'm still fighting against Spring config or Camel because
> Rollback
> >> does
> >> >>> not
> >> >>> >> occur. I have been able to configure Hibernate to use the same
> >> >>> >> TransactionManager as the one used by JMS
> >> >>> >>
> >> >>> >> Here is the different part of the config. I don't know where the
> >> issue
> >> >>> could
> >> >>> >> be !
> >> >>> >>
> >> >>> >> 1) ActiveMQ
> >> >>> >>
> >> >>> >> ...
> >> >>> >>
> >> >>> >>    <bean id="activemqConnectionFactory"
> >> >>> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >> >>> >>        <property name="brokerURL" value="tcp://localhost:61616"
> />
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>    <bean id="pooledConnectionFactory"
> >> >>> >> class="org.apache.activemq.pool.PooledConnectionFactoryBean">
> >> >>> >>        <property name="maxConnections" value="8" />
> >> >>> >>        <property name="maximumActive" value="500" />
> >> >>> >>        <property name="transactionManager"
> ref="transactionManager"
> >> />
> >> >>> >>        <property name="connectionFactory"
> >> >>> ref="activemqConnectionFactory"
> >> >>> >> />
> >> >>> >>        <property name="resourceName" value="activemq.default" />
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>    <bean id="resourceManager"
> >> >>> >> class="org.apache.activemq.pool.ActiveMQResourceManager"
> >> >>> >> init-method="recoverResource">
> >> >>> >>          <property name="transactionManager"
> >> ref="transactionManager" />
> >> >>> >>          <property name="connectionFactory"
> >> >>> ref="activemqConnectionFactory"
> >> >>> >> />
> >> >>> >>          <property name="resourceName" value="activemq.default"
> />
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>    <osgi:reference id="transactionManager"
> >> >>> >> interface="javax.transaction.TransactionManager" /> // This OSGI
> >> service
> >> >>> is
> >> >>> >> published by Geronimo Transaction bundle
> >> >>> >>
> >> >>> >>    <osgi:service ref="pooledConnectionFactory">
> >> >>> >>        <osgi:interfaces>
> >> >>> >>            <value>javax.jms.ConnectionFactory</value>
> >> >>> >>        </osgi:interfaces>
> >> >>> >>        <osgi:service-properties>
> >> >>> >>            <entry key="name" value="default"/>
> >> >>> >>        </osgi:service-properties>
> >> >>> >>    </osgi:service>
> >> >>> >>
> >> >>> >> 2) Camel ActiveMQComponent
> >> >>> >>
> >> >>> >>    <bean id="active-mq"
> >> >>> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >> >>> >>        <property name="transacted" value="true"/>
> >> >>> >>        <property name="connectionFactory">
> >> >>> >>            <osgi:reference
> interface="javax.jms.ConnectionFactory"/>
> >> //
> >> >>> >> OSGI service is published by ActiveMQ service
> >> >>> >>        </property>
> >> >>> >>        <property name="transactionManager">
> >> >>> >>            <osgi:reference
> >> >>> >>
> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >> >>> >>        </property>
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >> 2) Hibernate - DAO
> >> >>> >>
> >> >>> >>    <bean id="sessionFactory"
> >> >>> >>
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> >> >>> >>
> >> >>> >>        <property name="mappingLocations">
> >> >>> >>            <list>
> >> >>> >>
> >> >>> >>
> >> >>>
> >>
> <value>classpath*:META-INF/com/xpectis/x3s/platform/model/*.hbm.xml</value>
> >> >>> >>            </list>
> >> >>> >>        </property>
> >> >>> >>
> >> >>> >>        <property name="hibernateProperties">
> >> >>> >>            <props>
> >> >>> >>                <prop
> >> >>> >> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
> >> >>> >>                <prop key="hibernate.show_sql">true</prop>
> >> >>> >>                <prop key="hibernate.format_sql">true</prop>
> >> >>> >>                <prop
> >> >>> >> key="hibernate.cglib.use_reflection_optimizer">true</prop>
> >> >>> >>                <prop key="hibernate.jdbc.batch_size">10</prop>
> >> >>> >>                <prop
> >> >>> >>
> >> >>>
> >>
> key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
> >> >>> >>                <prop
> >> >>> >>
> >> >>>
> >>
> key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
> >> >>> >>            </props>
> >> >>> >>        </property>
> >> >>> >>        <property name="dataSource">
> >> >>> >>            <ref bean="dataSource" />
> >> >>> >>        </property>
> >> >>> >>
> >> >>> >> Remark : To avoid the JNDI lookup issue, we use
> >> springTransactionFactory
> >> >>> as
> >> >>> >> the TransactionFactory for Hibernate (
> >> >>> >> http://forum.springsource.org/showthread.php?p=215720)
> >> >>> >>
> >> >>> >> 3) Service layer
> >> >>> >>
> >> >>> >> Here is the definition of the service used from Camel route :
> >> >>> >>
> >> >>> >>    <bean id="notificationServiceTarget"
> >> >>> >>
> >> class="com.xpectis.x3s.platform.service.impl.NotificationServiceImpl">
> >> >>> >>            <property name="notificationDAO">
> >> >>> >>            <osgi:reference
> >> >>> >> interface="com.xpectis.x3s.platform.dao.NotificationDAO"/>
> >> >>> >>        </property>
> >> >>> >>
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>   <!-- Abstract service using the Geronimo Transaction Manager
> -->
> >> >>> >>    <bean id="abstractService" abstract="true"
> >> >>> >>
> >> >>>
> >>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
> >> >>> >>         <property name="transactionManager">
> >> >>> >>            <osgi:reference
> >> >>> >>
> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >> >>> >>        </property>
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>    <bean id="notificationService"
> >> >>> >>          parent="abstractService"
> >> >>> >>
> >> >>> >>
> >> >>>
> >>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
> >> >>> >>
> >> >>> >>        <property name="target">
> >> >>> >>            <ref bean="notificationServiceTarget" />
> >> >>> >>        </property>
> >> >>> >>
> >> >>> >>        <property name="transactionAttributes">
> >> >>> >>            <props>
> >> >>> >>                <prop key="*">PROPAGATION_REQUIRED</prop>
> >> >>> >>            </props>
> >> >>> >>        </property>
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >> 4) Route
> >> >>> >>
> >> >>> >>    <bean id="myPolicy"
> >> >>> class="org.apache.camel.processor.RedeliveryPolicy">
> >> >>> >>        <property name="maximumRedeliveries" value="1"/>
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>    <bean id="txErrorHandler"
> >> >>> >>
> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
> >> >>> >>        <property name="springTransactionPolicy"
> >> >>> >> ref="PROPAGATION_REQUIRED"/>
> >> >>> >>        <property name="redeliveryPolicy" ref="myPolicy"/>
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>    <bean id="PROPAGATION_REQUIRED"
> >> >>> >> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >> >>> >>        <property name="transactionManager">
> >> >>> >>            <osgi:reference
> >> >>> >>
> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >> >>> >>        </property>
> >> >>> >>    </bean>
> >> >>> >>
> >> >>> >>        <camel:route errorHandlerRef="txErrorHandler">
> >> >>> >>            <camel:from ref="queueQuickFixInEndpoint" />
> >> >>> >>            <camel:convertBodyTo type="quickfix.Message" />
> >> >>> >>            <camel:transacted ref="PROPAGATION_REQUIRED"/>
> >> >>> >>            <camel:bean ref="serviceHelper"
> >> method="createNotification"
> >> >>> />
> >> >>> >>            <camel:bean ref="serviceHelper" method="generateError"
> />
> >> >>> >>            <camel:to ref="directNotificationEndpoint" />
> >> >>> >>        </camel:route>
> >> >>> >>
> >> >>> >> Any ideas are welcome
> >> >>> >>
> >> >>> >> Regards,
> >> >>> >>
> >> >>> >> Charles Moulliard
> >> >>> >> Senior Enterprise Architect
> >> >>> >> Apache Camel Committer
> >> >>> >>
> >> >>> >> *****************************
> >> >>> >> blog : http://cmoulliard.blogspot.com
> >> >>> >>
> >> >>> >>
> >> >>> >> On Thu, Jul 2, 2009 at 5:02 PM, Charles Moulliard <
> >> [hidden email]
> >> >>> >wrote:
> >> >>> >>
> >> >>> >>> OK. I will try to create my own Hibernate JTATransaction manager
> as
> >> the
> >> >>> >>> existing try to perform a JNDI lookup to find the transaction
> >> manager
> >> >>> on
> >> >>> >>> OSGI platform (inheritage from J2EE world)
> >> >>> >>>
> >> >>> >>>
> >> >>> >>>
> >> >>>
> >>
> http://mail-archives.apache.org/mod_mbox/servicemix-dev/200904.mbox/%3Cb23ecedc0904020615y55df4d0fhb303a2ea22df7a53@...%3E
> >> >>> >>>
> >> >>> >>>
> >> >>> >>> Charles Moulliard
> >> >>> >>> Senior Enterprise Architect
> >> >>> >>> Apache Camel Committer
> >> >>> >>>
> >> >>> >>> *****************************
> >> >>> >>> blog : http://cmoulliard.blogspot.com
> >> >>> >>>
> >> >>> >>>
> >> >>> >>> On Thu, Jul 2, 2009 at 4:56 PM, Claus Ibsen <
> [hidden email]
> >> >
> >> >>> wrote:
> >> >>> >>>
> >> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> >> >>> [hidden email]>
> >> >>> >>>> wrote:
> >> >>> >>>> > queueQuickFixInEndpoint is a JMS queue.
> >> >>> >>>> >
> >> >>> >>>> > I will add the ref to the transacted and retest
> >> >>> >>>> >
> >> >>> >>>> > Question : I suppose that rollback will not occur if by
> example
> >> JMS
> >> >>> and
> >> >>> >>>> DB
> >> >>> >>>> > (=Hibernate) does not use the same TransactionManager and
> don't
> >> use
> >> >>> this
> >> >>> >>>> > spring class together :
> >> >>> >>>> > org.springframework.transaction.PlatformTransactionManager
> >> >>> >>>> Yes they must be configured to use the same TX manager.
> >> >>> >>>>
> >> >>> >>>>
> >> >>> >>>> >
> >> >>> >>>> > Regards,
> >> >>> >>>> >
> >> >>> >>>> > Charles Moulliard
> >> >>> >>>> > Senior Enterprise Architect
> >> >>> >>>> > Apache Camel Committer
> >> >>> >>>> >
> >> >>> >>>> > *****************************
> >> >>> >>>> > blog : http://cmoulliard.blogspot.com
> >> >>> >>>> >
> >> >>> >>>> >
> >> >>> >>>> > On Thu, Jul 2, 2009 at 4:46 PM, Claus Ibsen <
> >> [hidden email]>
> >> >>> >>>> wrote:
> >> >>> >>>> >
> >> >>> >>>> >> Transacted also have a ref attribute
> >> >>> >>>> >>
> >> >>> >>>> >> <transacted ref="required"/>
> >> >>> >>>> >>
> >> >>> >>>> >> Is queueQuickFixInEndpoint a JMS queue?
> >> >>> >>>> >> You need to use a TX manager that can do both JMS and DB.
> >> >>> >>>> >>
> >> >>> >>>> >>
> >> >>> >>>> >>
> >> >>> >>>> >> On Thu, Jul 2, 2009 at 4:31 PM, Charles Moulliard<
> >> >>> [hidden email]
> >> >>> >>>> >
> >> >>> >>>> >> wrote:
> >> >>> >>>> >> > I have been able to solve my problem by adding the
> following
> >> bean
> >> >>> >>>> >> definition
> >> >>> >>>> >> > :
> >> >>> >>>> >> >
> >> >>> >>>> >> >    <bean id="required"
> >> >>> >>>> >> >
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >> >>> >>>> >> >        <property name="transactionManager">
> >> >>> >>>> >> >            <osgi:reference
> >> >>> >>>> >> >
> >> >>> >>>>
> >> >>>
> >> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >> >>> >>>> >> >        </property>
> >> >>> >>>> >> >    </bean>
> >> >>> >>>> >> >
> >> >>> >>>> >> > and in the route
> >> >>> >>>> >> >
> >> >>> >>>> >> >        <camel:route>
> >> >>> >>>> >> >            <camel:from ref="queueQuickFixInEndpoint" />
> >> >>> >>>> >> >            <camel:convertBodyTo type="quickfix.Message" />
> >> >>> >>>> >> >            <camel:transacted/>
> >> >>> >>>> >> >            <camel:policy ref="required" />
> >> >>> >>>> >> >            <camel:bean ref="serviceHelper"
> >> >>> >>>> method="createNotification" />
> >> >>> >>>> >> >            <camel:bean ref="serviceHelper"
> >> method="generateError"
> >> >>> />
> >> >>> >>>> >> >            <camel:to ref="directNotificationEndpoint" />
> >> >>> >>>> >> >        </camel:route>
> >> >>> >>>> >> >
> >> >>> >>>> >> > Unfortunately, the rollback does not occur in the DB and 6
> >> >>> records
> >> >>> >>>> have
> >> >>> >>>> >> been
> >> >>> >>>> >> > created by the method createNotification when error has
> been
> >> >>> raised
> >> >>> >>>> by
> >> >>> >>>> >> the
> >> >>> >>>> >> > method generateError.
> >> >>> >>>> >> >
> >> >>> >>>> >> > What is missing ?
> >> >>> >>>> >> >
> >> >>> >>>> >> > Charles Moulliard
> >> >>> >>>> >> > Senior Enterprise Architect
> >> >>> >>>> >> > Apache Camel Committer
> >> >>> >>>> >> >
> >> >>> >>>> >> > *****************************
> >> >>> >>>> >> > blog : http://cmoulliard.blogspot.com
> >> >>> >>>> >> >
> >> >>> >>>> >> >
> >> >>> >>>> >> > On Thu, Jul 2, 2009 at 4:19 PM, Charles Moulliard <
> >> >>> >>>> [hidden email]
> >> >>> >>>> >> >wrote:
> >> >>> >>>> >> >
> >> >>> >>>> >> >> When I compare the example :
> >> >>> JMSTransactionalClientRollbackTest.xml
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>     <!-- START SNIPPET: e1 -->
> >> >>> >>>> >> >>     <!-- setup JMS connection factory -->
> >> >>> >>>> >> >>     <bean id="jmsConnectionFactory"
> >> >>> >>>> >> >> class="org.apache.activemq.ActiveMQConnectionFactory">
> >> >>> >>>> >> >>         <property name="brokerURL"
> >> >>> >>>> >> >>
> >> >>> >>>>
> >> >>>
> >> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
> >> >>> >>>> >> >>     </bean>
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
> >> >>> >>>> >> >>     <bean id="jmsTransactionManager"
> >> >>> >>>> >> >>
> >> >>> class="org.springframework.jms.connection.JmsTransactionManager">
> >> >>> >>>> >> >>         <property name="connectionFactory"
> >> >>> >>>> ref="jmsConnectionFactory"/>
> >> >>> >>>> >> >>     </bean>
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>     <!-- define our activemq component -->
> >> >>> >>>> >> >>     <bean id="activemq"
> >> >>> >>>> >> >>
> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
> >> >>> >>>> >> >>         <property name="connectionFactory"
> >> >>> >>>> ref="jmsConnectionFactory"/>
> >> >>> >>>> >> >>         <!-- define the jms consumer/producer as
> transacted
> >> -->
> >> >>> >>>> >> >>         <property name="transacted" value="true"/>
> >> >>> >>>> >> >>         <!-- setup the transaction manager to use -->
> >> >>> >>>> >> >>         <!-- if not provided then Camel will automatic
> use a
> >> >>> >>>> >> >> JmsTransactionManager, however if you
> >> >>> >>>> >> >>              for instance use a JTA transaction manager
> then
> >> you
> >> >>> >>>> must
> >> >>> >>>> >> >> configure it -->
> >> >>> >>>> >> >>         <property name="transactionManager"
> >> >>> >>>> >> ref="jmsTransactionManager"/>
> >> >>> >>>> >> >>     </bean>
> >> >>> >>>> >> >>     <!-- END SNIPPET: e1 -->
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>     <!-- START SNIPPET: e2 -->
> >> >>> >>>> >> >>     <camelContext xmlns="
> >> http://camel.apache.org/schema/spring
> >> >>> ">
> >> >>> >>>> >> >>         <route>
> >> >>> >>>> >> >>             <!-- 1: from the jms queue -->
> >> >>> >>>> >> >>             <from uri="activemq:queue:okay"/>
> >> >>> >>>> >> >>             <!-- 2: mark this route as transacted -->
> >> >>> >>>> >> >>             <transacted/>
> >> >>> >>>> >> >>             <!-- 3: call our business logic that is
> >> myProcessor
> >> >>> -->
> >> >>> >>>> >> >>             <process ref="myProcessor"/>
> >> >>> >>>> >> >>             <!-- 4: if success then send it to the mock
> -->
> >> >>> >>>> >> >>             <to uri="mock:result"/>
> >> >>> >>>> >> >>         </route>
> >> >>> >>>> >> >>     </camelContext>
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> with mine.
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> What is different concerns the TransactionManager used.
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> In the example, this is the Spring one:
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>     <!-- setup spring jms TX manager -->
> >> >>> >>>> >> >>     <bean id="jmsTransactionManager"
> >> >>> >>>> >> >>
> >> >>> class="org.springframework.jms.connection.JmsTransactionManager">
> >> >>> >>>> >> >>         <property name="connectionFactory"
> >> >>> >>>> ref="jmsConnectionFactory"/>
> >> >>> >>>> >> >>     </bean>
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> and in my case, ActiveMQ is configured to use Geronimo
> >> >>> Transaction
> >> >>> >>>> >> Manager
> >> >>> >>>> >> >> bundle (which in fact uses spring Transaction manager :
> >> >>> >>>> >> >>
> org.springframework.transaction.jta.JtaTransactionManager;)
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> I suppose that in the example, the policy is defined by
> >> default
> >> >>> by
> >> >>> >>>> >> spring
> >> >>> >>>> >> >> when instantiating the class :
> >> >>> >>>> >> >> org.springframework.jms.connection.JmsTransactionManager
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> Is it possible to do the same using a JtaTransaction
> manager
> >> ?
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> Regards,
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> Charles Moulliard
> >> >>> >>>> >> >> Senior Enterprise Architect
> >> >>> >>>> >> >> Apache Camel Committer
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> *****************************
> >> >>> >>>> >> >> blog : http://cmoulliard.blogspot.com
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>
> >> >>> >>>> >> >> On Thu, Jul 2, 2009 at 3:57 PM, Claus Ibsen <
> >> >>> [hidden email]>
> >> >>> >>>> >> wrote:
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>> Hi
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
> >> >>> >>>> [hidden email]
> >> >>> >>>> >> >
> >> >>> >>>> >> >>> wrote:
> >> >>> >>>> >> >>> > Camel generates the following error with my route :
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>> > Route
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>> >        <camel:route>
> >> >>> >>>> >> >>> >            <camel:from ref="queueQuickFixInEndpoint"
> />
> >> >>> >>>> >> >>> >            <camel:convertBodyTo
> type="quickfix.Message"
> >> />
> >> >>> >>>> >> >>> >            <camel:transacted/>
> >> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
> >> >>> >>>> >> method="createNotification"
> >> >>> >>>> >> >>> />
> >> >>> >>>> >> >>> >            <camel:bean ref="serviceHelper"
> >> >>> method="generateError"
> >> >>> >>>> />
> >> >>> >>>> >> >>> >            <camel:to ref="directNotificationEndpoint"
> />
> >> >>> >>>> >> >>> >        </camel:route>
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>> > It seems that policy must be defined but in the
> example
> >> here
> >> >>> it
> >> >>> >>>> is
> >> >>> >>>> >> not
> >> >>> >>>> >> >>> > mentioned :
> >> >>> http://camel.apache.org/transactional-client.html
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>> > Error :
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>> > 15:43:07,838 | ERROR | xtenderThread-30 |
> >> >>> ContextLoaderListener
> >> >>> >>>> >> >>>    |
> >> >>> >>>> >> >>> > BundleApplicationContextListener   50 | Application
> >> context
> >> >>> >>>> refresh
> >> >>> >>>> >> >>> failed
> >> >>> >>>> >> >>> >
> >> >>> (OsgiBundleXmlApplicationContext(bundle=com.xpectis.x3s.x3s-core,
> >> >>> >>>> >> >>> > config=osgibundle:/META-INF/spring/*.xml))
> >> >>> >>>> >> >>> > org.apache.camel.RuntimeCamelException:
> >> >>> >>>> >> >>> java.lang.IllegalArgumentException:
> >> >>> >>>> >> >>> > policy must be specified on: Transacted[ref: null]
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:465)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
> >> >>> >>>> >> >>> >    at java.lang.Thread.run(Thread.java:619)
> >> >>> >>>> >> >>> > Caused by: java.lang.IllegalArgumentException: policy
> >> must be
> >> >>> >>>> >> specified
> >> >>> >>>> >> >>> on:
> >> >>> >>>> >> >>> > Transacted[ref: null]
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >>
> >> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:258)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:129)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:226)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:111)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:294)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:120)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:552)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:969)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:946)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >>
> >> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:863)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:99)
> >> >>> >>>> >> >>> >    at
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >>
> >> >>> >>>>
> >> >>>
> >>
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:119)
> >> >>> >>>> >> >>> > Charles Moulliard
> >> >>> >>>> >> >>> > Senior Enterprise Architect
> >> >>> >>>> >> >>> > Apache Camel Committer
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>> > *****************************
> >> >>> >>>> >> >>> > blog : http://cmoulliard.blogspot.com
> >> >>> >>>> >> >>> >
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>> --
> >> >>> >>>> >> >>> Claus Ibsen
> >> >>> >>>> >> >>> Apache Camel Committer
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>> Open Source Integration: http://fusesource.com
> >> >>> >>>> >> >>> Blog: http://davsclaus.blogspot.com/
> >> >>> >>>> >> >>> Twitter: http://twitter.com/davsclaus
> >> >>> >>>> >> >>>
> >> >>> >>>> >> >>
> >> >>> >>>> >> >>
> >> >>> >>>> >> >
> >> >>> >>>> >>
> >> >>> >>>> >>
> >> >>> >>>> >>
> >> >>> >>>> >> --
> >> >>> >>>> >> Claus Ibsen
> >> >>> >>>> >> Apache Camel Committer
> >> >>> >>>> >>
> >> >>> >>>> >> Open Source Integration: http://fusesource.com
> >> >>> >>>> >> Blog: http://davsclaus.blogspot.com/
> >> >>> >>>> >> Twitter: http://twitter.com/davsclaus
> >> >>> >>>> >>
> >> >>> >>>> >
> >> >>> >>>>
> >> >>> >>>>
> >> >>> >>>>
> >> >>> >>>> --
> >> >>> >>>> Claus Ibsen
> >> >>> >>>> Apache Camel Committer
> >> >>> >>>>
> >> >>> >>>> Open Source Integration: http://fusesource.com
> >> >>> >>>> Blog: http://davsclaus.blogspot.com/
> >> >>> >>>> Twitter: http://twitter.com/davsclaus
> >> >>> >>>>
> >> >>> >>>
> >> >>> >>>
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > --
> >> >>> > Claus Ibsen
> >> >>> > Apache Camel Committer
> >> >>> >
> >> >>> > Open Source Integration: http://fusesource.com
> >> >>> > Blog: http://davsclaus.blogspot.com/
> >> >>> > Twitter: http://twitter.com/davsclaus
> >> >>> >
> >> >>>
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Claus Ibsen
> >> >>> Apache Camel Committer
> >> >>>
> >> >>> Open Source Integration: http://fusesource.com
> >> >>> Blog: http://davsclaus.blogspot.com/
> >> >>> Twitter: http://twitter.com/davsclaus
> >> >>>
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> > ------------------------
> >> > Blog: http://gnodet.blogspot.com/
> >> > ------------------------
> >> > Open Source SOA
> >> > http://fusesource.com
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
12
Loading...