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/%3cb23ecedc0904020615y55df4d0fhb303a2ea22df7...@mail.gmail.com%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 <claus.ib...@gmail.com> wrote: > On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<cmoulli...@gmail.com> > 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 <claus.ib...@gmail.com> > 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<cmoulli...@gmail.com> > >> 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 < > cmoulli...@gmail.com > >> >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&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 <claus.ib...@gmail.com> > >> wrote: > >> >> > >> >>> Hi > >> >>> > >> >>> Yeah you need to add all the spring transaction stuff. > >> >>> > >> >>> > >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard< > cmoulli...@gmail.com > >> > > >> >>> 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 >