Error using Transacted with Camel 2.0

View: New views
10 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: Error using Transacted with Camel 2.0

by cmoulliard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No. In the route presented here I don't make 2 independant DB calls. Only
one. The second bean called (generateError) only do a throw (without any
Hibernate/DB call)

By the way, in the example
apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
two DB calls are made by two different beans and rollback is done !!

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

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


On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...> wrote:

> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...> 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<cmoulliard@...>
> 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 <claus.ibsen@...>
> wrote:
> >>
> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<gnodet@...>
> 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<cmoulliard@...
> >
> >>> 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 <claus.ibsen@...
> >
> >>> 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<claus.ibsen@...
> >
> >>> 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<
> >>> cmoulliard@...>
> >>> >>> 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 <
> >>> cmoulliard@...
> >>> >>> >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 <
> claus.ibsen@...
> >>> >
> >>> >>> wrote:
> >>> >>> >>>
> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> >>> >>> cmoulliard@...>
> >>> >>> >>>> 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.ibsen@...>
> >>> >>> >>>> 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<
> >>> >>> cmoulliard@...
> >>> >>> >>>> >
> >>> >>> >>>> >> 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 <
> >>> >>> >>>> cmoulliard@...
> >>> >>> >>>> >> >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.ibsen@...>
> >>> >>> >>>> >> wrote:
> >>> >>> >>>> >> >>
> >>> >>> >>>> >> >>> Hi
> >>> >>> >>>> >> >>>
> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
> >>> >>> >>>> >> >>>
> >>> >>> >>>> >> >>>
> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
> >>> >>> >>>> cmoulliard@...
> >>> >>> >>>> >> >
> >>> >>> >>>> >> >>> 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
>
Charles Moulliard
SOA Architect

My Blog : http://cmoulliard.blogspot.com/ 

Re: Error using Transacted with Camel 2.0

by Claus Ibsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...> wrote:
> No. In the route presented here I don't make 2 independant DB calls. Only
> one. The second bean called (generateError) only do a throw (without any
> Hibernate/DB call)
>
> By the way, in the example
> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
> two DB calls are made by two different beans and rollback is done !!
Yes and it is because it uses a DB TX manager

    <!-- spring transaction manager -->
    <bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

This TX manager knows about DB stuff.




>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...> wrote:
>
>> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...> 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<cmoulliard@...>
>> 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 <claus.ibsen@...>
>> wrote:
>> >>
>> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<gnodet@...>
>> 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<cmoulliard@...
>> >
>> >>> 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 <claus.ibsen@...
>> >
>> >>> 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<claus.ibsen@...
>> >
>> >>> 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<
>> >>> cmoulliard@...>
>> >>> >>> 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 <
>> >>> cmoulliard@...
>> >>> >>> >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 <
>> claus.ibsen@...
>> >>> >
>> >>> >>> wrote:
>> >>> >>> >>>
>> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>> >>> >>> cmoulliard@...>
>> >>> >>> >>>> 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.ibsen@...>
>> >>> >>> >>>> 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<
>> >>> >>> cmoulliard@...
>> >>> >>> >>>> >
>> >>> >>> >>>> >> 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 <
>> >>> >>> >>>> cmoulliard@...
>> >>> >>> >>>> >> >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.ibsen@...>
>> >>> >>> >>>> >> wrote:
>> >>> >>> >>>> >> >>
>> >>> >>> >>>> >> >>> Hi
>> >>> >>> >>>> >> >>>
>> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction stuff.
>> >>> >>> >>>> >> >>>
>> >>> >>> >>>> >> >>>
>> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>> >>> >>> >>>> cmoulliard@...
>> >>> >>> >>>> >> >
>> >>> >>> >>>> >> >>> 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
>>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Error using Transacted with Camel 2.0

by cmoulliard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK. I will change my config to use a separate TransactionManager for DB
stuffs.

My idea was to use the same transaction manager (JTA) in the application for
JMS, DB, ... transactions but If this is not possible ...

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

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


On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...> wrote:

> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...>
> wrote:
> > No. In the route presented here I don't make 2 independant DB calls. Only
> > one. The second bean called (generateError) only do a throw (without any
> > Hibernate/DB call)
> >
> > By the way, in the example
> >
> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
> > two DB calls are made by two different beans and rollback is done !!
> Yes and it is because it uses a DB TX manager
>
>    <!-- spring transaction manager -->
>    <bean id="txManager"
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>        <property name="dataSource" ref="dataSource"/>
>    </bean>
>
> This TX manager knows about DB stuff.
>
>
>
>
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
> wrote:
> >
> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
> 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<cmoulliard@...>
> >> 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 <claus.ibsen@...>
> >> wrote:
> >> >>
> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<gnodet@...>
> >> 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<
> cmoulliard@...
> >> >
> >> >>> 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 <
> claus.ibsen@...
> >> >
> >> >>> 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<
> claus.ibsen@...
> >> >
> >> >>> 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<
> >> >>> cmoulliard@...>
> >> >>> >>> 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 <
> >> >>> cmoulliard@...
> >> >>> >>> >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 <
> >> claus.ibsen@...
> >> >>> >
> >> >>> >>> wrote:
> >> >>> >>> >>>
> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> >> >>> >>> cmoulliard@...>
> >> >>> >>> >>>> 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.ibsen@...>
> >> >>> >>> >>>> 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<
> >> >>> >>> cmoulliard@...
> >> >>> >>> >>>> >
> >> >>> >>> >>>> >> 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 <
> >> >>> >>> >>>> cmoulliard@...
> >> >>> >>> >>>> >> >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.ibsen@...>
> >> >>> >>> >>>> >> wrote:
> >> >>> >>> >>>> >> >>
> >> >>> >>> >>>> >> >>> Hi
> >> >>> >>> >>>> >> >>>
> >> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction
> stuff.
> >> >>> >>> >>>> >> >>>
> >> >>> >>> >>>> >> >>>
> >> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
> >> >>> >>> >>>> cmoulliard@...
> >> >>> >>> >>>> >> >
> >> >>> >>> >>>> >> >>> 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
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Charles Moulliard
SOA Architect

My Blog : http://cmoulliard.blogspot.com/ 

Re: Error using Transacted with Camel 2.0

by gnodet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It is certainly possible to do that.  You need to configure the JMS
connection factory and the JDBC datasource so that they are aware of
the transaction manager.
How did you set up those resources ? They are the critical ones for using XA.

On Fri, Jul 3, 2009 at 16:14, Charles Moulliard<cmoulliard@...> wrote:

> OK. I will change my config to use a separate TransactionManager for DB
> stuffs.
>
> My idea was to use the same transaction manager (JTA) in the application for
> JMS, DB, ... transactions but If this is not possible ...
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...> wrote:
>
>> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...>
>> wrote:
>> > No. In the route presented here I don't make 2 independant DB calls. Only
>> > one. The second bean called (generateError) only do a throw (without any
>> > Hibernate/DB call)
>> >
>> > By the way, in the example
>> >
>> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
>> > two DB calls are made by two different beans and rollback is done !!
>> Yes and it is because it uses a DB TX manager
>>
>>    <!-- spring transaction manager -->
>>    <bean id="txManager"
>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>>        <property name="dataSource" ref="dataSource"/>
>>    </bean>
>>
>> This TX manager knows about DB stuff.
>>
>>
>>
>>
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>> >
>> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
>> wrote:
>> >
>> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
>> 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<cmoulliard@...>
>> >> 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 <claus.ibsen@...>
>> >> wrote:
>> >> >>
>> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<gnodet@...>
>> >> 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<
>> cmoulliard@...
>> >> >
>> >> >>> 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 <
>> claus.ibsen@...
>> >> >
>> >> >>> 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<
>> claus.ibsen@...
>> >> >
>> >> >>> 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<
>> >> >>> cmoulliard@...>
>> >> >>> >>> 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 <
>> >> >>> cmoulliard@...
>> >> >>> >>> >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 <
>> >> claus.ibsen@...
>> >> >>> >
>> >> >>> >>> wrote:
>> >> >>> >>> >>>
>> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>> >> >>> >>> cmoulliard@...>
>> >> >>> >>> >>>> 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.ibsen@...>
>> >> >>> >>> >>>> 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<
>> >> >>> >>> cmoulliard@...
>> >> >>> >>> >>>> >
>> >> >>> >>> >>>> >> 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 <
>> >> >>> >>> >>>> cmoulliard@...
>> >> >>> >>> >>>> >> >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.ibsen@...>
>> >> >>> >>> >>>> >> wrote:
>> >> >>> >>> >>>> >> >>
>> >> >>> >>> >>>> >> >>> Hi
>> >> >>> >>> >>>> >> >>>
>> >> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction
>> stuff.
>> >> >>> >>> >>>> >> >>>
>> >> >>> >>> >>>> >> >>>
>> >> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>> >> >>> >>> >>>> cmoulliard@...
>> >> >>> >>> >>>> >> >
>> >> >>> >>> >>>> >> >>> 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
>> >>
>> >
>>
>>
>>
>> --
>> 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

Re: Error using Transacted with Camel 2.0

by cmoulliard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is a snapshot of the configs used  :

1) 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>

    <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" />

    <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 with Hibernate JTATransaction
Factory, I use springTransactionFactory (see here for more info
http://forum.springsource.org/showthread.php?p=215720)

3) Service layer

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

    <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>

   <!-- 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="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>

4) Route

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

    <bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <property name="transactionManager">
            <osgi:reference
interface="org.springframework.transaction.PlatformTransactionManager"/>
        </property>
    </bean>
         <!-- Core component
         Flow IN to OUT
         Process P1
        -->
        <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>

        <!-- Core component
         Flow IN to OUT
         Process P2
        -->
        <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>

5) Code of the method where the injected Spring service is called

    public Request createRequest(@Header(value = "messageType") String
messageType,
            @Header(value = "CamelFileNameOnly") String fileName, @Body
String body) {

        if (LOG.isDebugEnabled()) {
            LOG.debug(">> Header message Type : '" + messageType + "'");
            LOG.debug(">> Header CamelFileNameOnly : ' " + fileName + "'");
            LOG.debug(">> Body : " + body);
        }

        // 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);

        // add the request object to the exchange
        // exchange.getOut().setBody(request);

        return request;
    }

and the bundles used for Tx/Spring/ActiveMq stuffs. Other are standards like
Hibernate/MySQL/Spring and Camel 2.0-SNAPSHOT

karaf@root:osgi> list | grep Tx
[  57] [Active     ] [           ] [   60] Geronimo TxManager :: Transaction
(2.2.0.r634076)
[  60] [Active     ] [           ] [   60] Geronimo TxManager :: Connector
(2.2.0.r634076)
karaf@root:osgi> list | grep Trans
[  57] [Active     ] [           ] [   60] Geronimo TxManager :: Transaction
(2.2.0.r634076)
[  58] [Active     ] [           ] [   60] Spring Transaction (2.5.6.SEC01)
[  59] [Active     ] [           ] [   60] Apache Felix Transaction
(0.9.0.SNAPSHOT)

For information

karaf@root:osgi> list | grep Spring
[  16] [Active     ] [           ] [   30] Spring Core (2.5.6.SEC01)
[  18] [Active     ] [           ] [   30] Spring AOP (2.5.6.SEC01)
[  38] [Active     ] [           ] [   30] Spring Beans (2.5.6.SEC01)
[  40] [Active     ] [           ] [   30] Spring Context (2.5.6.SEC01)
[  44] [Active     ] [Created    ] [   30] Apache Felix Karaf :: Spring
Deployer (1.2.0.SNAPSHOT)
[  58] [Active     ] [           ] [   60] Spring Transaction (2.5.6.SEC01)
[  73] [Active     ] [           ] [   60] Spring JMS (2.5.6.SEC01)
[  83] [Active     ] [           ] [   60] Spring ORM (2.5.6.SEC01)
[  84] [Active     ] [           ] [   60] Spring JDBC (2.5.6.SEC01)
karaf@root:osgi> list | grep activemq
[  65] [Active     ] [           ] [   60] activemq-core (5.2.0)
[  66] [Active     ] [           ] [   60] activemq-ra (5.2.0)
[  67] [Active     ] [           ] [   60] activemq-console (5.2.0)
[  68] [Active     ] [           ] [   60] activemq-pool (5.2.0)
[  75] [Active     ] [           ] [   60] activemq-camel (5.2.0)
[  90] [Active     ] [           ] [   60] x3s-activemq (1.0.0.SNAPSHOT)


Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

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


On Fri, Jul 3, 2009 at 4:17 PM, Guillaume Nodet <gnodet@...> wrote:

> It is certainly possible to do that.  You need to configure the JMS
> connection factory and the JDBC datasource so that they are aware of
> the transaction manager.
> How did you set up those resources ? They are the critical ones for using
> XA.
>
> On Fri, Jul 3, 2009 at 16:14, Charles Moulliard<cmoulliard@...>
> wrote:
> > OK. I will change my config to use a separate TransactionManager for DB
> > stuffs.
> >
> > My idea was to use the same transaction manager (JTA) in the application
> for
> > JMS, DB, ... transactions but If this is not possible ...
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...>
> wrote:
> >
> >> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...>
> >> wrote:
> >> > No. In the route presented here I don't make 2 independant DB calls.
> Only
> >> > one. The second bean called (generateError) only do a throw (without
> any
> >> > Hibernate/DB call)
> >> >
> >> > By the way, in the example
> >> >
> >>
> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
> >> > two DB calls are made by two different beans and rollback is done !!
> >> Yes and it is because it uses a DB TX manager
> >>
> >>    <!-- spring transaction manager -->
> >>    <bean id="txManager"
> >>
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> >>        <property name="dataSource" ref="dataSource"/>
> >>    </bean>
> >>
> >> This TX manager knows about DB stuff.
> >>
> >>
> >>
> >>
> >> >
> >> > Regards,
> >> >
> >> > Charles Moulliard
> >> > Senior Enterprise Architect
> >> > Apache Camel Committer
> >> >
> >> > *****************************
> >> > blog : http://cmoulliard.blogspot.com
> >> >
> >> >
> >> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
> >> wrote:
> >> >
> >> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
> >> 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<
> cmoulliard@...>
> >> >> 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 <
> claus.ibsen@...>
> >> >> wrote:
> >> >> >>
> >> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<
> gnodet@...>
> >> >> 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<
> >> cmoulliard@...
> >> >> >
> >> >> >>> 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 <
> >> claus.ibsen@...
> >> >> >
> >> >> >>> 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<
> >> claus.ibsen@...
> >> >> >
> >> >> >>> 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<
> >> >> >>> cmoulliard@...>
> >> >> >>> >>> 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 <
> >> >> >>> cmoulliard@...
> >> >> >>> >>> >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 <
> >> >> claus.ibsen@...
> >> >> >>> >
> >> >> >>> >>> wrote:
> >> >> >>> >>> >>>
> >> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> >> >> >>> >>> cmoulliard@...>
> >> >> >>> >>> >>>> 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.ibsen@...>
> >> >> >>> >>> >>>> 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<
> >> >> >>> >>> cmoulliard@...
> >> >> >>> >>> >>>> >
> >> >> >>> >>> >>>> >> 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 <
> >> >> >>> >>> >>>> cmoulliard@...
> >> >> >>> >>> >>>> >> >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.ibsen@...>
> >> >> >>> >>> >>>> >> wrote:
> >> >> >>> >>> >>>> >> >>
> >> >> >>> >>> >>>> >> >>> Hi
> >> >> >>> >>> >>>> >> >>>
> >> >> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction
> >> stuff.
> >> >> >>> >>> >>>> >> >>>
> >> >> >>> >>> >>>> >> >>>
> >> >> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles
> Moulliard<
> >> >> >>> >>> >>>> cmoulliard@...
> >> >> >>> >>> >>>> >> >
> >> >> >>> >>> >>>> >> >>> 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
> >> >> >>>
>
Charles Moulliard
SOA Architect

My Blog : http://cmoulliard.blogspot.com/ 

Re: Error using Transacted with Camel 2.0

by cmoulliard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I use as TransactionManager

org.springframework.orm.hibernate3.HibernateTransactionManager

in DAO layer
in Spring layer
in Camel route

instead of

org.springframework.transaction.PlatformTransactionManager

It works. The transaction is well rollbacked !!!!! yes yes yes yes

If you find a solution to use the JTATransactionManager Guillaume, you are
welcome ;-)

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

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


On Fri, Jul 3, 2009 at 4:14 PM, Charles Moulliard <cmoulliard@...>wrote:

> OK. I will change my config to use a separate TransactionManager for DB
> stuffs.
>
> My idea was to use the same transaction manager (JTA) in the application
> for JMS, DB, ... transactions but If this is not possible ...
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...> wrote:
>
>> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...>
>> wrote:
>> > No. In the route presented here I don't make 2 independant DB calls.
>> Only
>> > one. The second bean called (generateError) only do a throw (without any
>> > Hibernate/DB call)
>> >
>> > By the way, in the example
>> >
>> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
>> > two DB calls are made by two different beans and rollback is done !!
>> Yes and it is because it uses a DB TX manager
>>
>>    <!-- spring transaction manager -->
>>    <bean id="txManager"
>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>>        <property name="dataSource" ref="dataSource"/>
>>    </bean>
>>
>> This TX manager knows about DB stuff.
>>
>>
>>
>>
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>> >
>> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
>> wrote:
>> >
>> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
>> 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<cmoulliard@...
>> >
>> >> 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 <claus.ibsen@...
>> >
>> >> wrote:
>> >> >>
>> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<gnodet@...>
>> >> 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<
>> cmoulliard@...
>> >> >
>> >> >>> 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 <
>> claus.ibsen@...
>> >> >
>> >> >>> 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<
>> claus.ibsen@...
>> >> >
>> >> >>> 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<
>> >> >>> cmoulliard@...>
>> >> >>> >>> 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 <
>> >> >>> cmoulliard@...
>> >> >>> >>> >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 <
>> >> claus.ibsen@...
>> >> >>> >
>> >> >>> >>> wrote:
>> >> >>> >>> >>>
>> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>> >> >>> >>> cmoulliard@...>
>> >> >>> >>> >>>> 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.ibsen@...>
>> >> >>> >>> >>>> 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<
>> >> >>> >>> cmoulliard@...
>> >> >>> >>> >>>> >
>> >> >>> >>> >>>> >> 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 <
>> >> >>> >>> >>>> cmoulliard@...
>> >> >>> >>> >>>> >> >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.ibsen@...>
>> >> >>> >>> >>>> >> wrote:
>> >> >>> >>> >>>> >> >>
>> >> >>> >>> >>>> >> >>> Hi
>> >> >>> >>> >>>> >> >>>
>> >> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction
>> stuff.
>> >> >>> >>> >>>> >> >>>
>> >> >>> >>> >>>> >> >>>
>> >> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>> >> >>> >>> >>>> cmoulliard@...
>> >> >>> >>> >>>> >> >
>> >> >>> >>> >>>> >> >>> 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
>> >>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
Charles Moulliard
SOA Architect

My Blog : http://cmoulliard.blogspot.com/ 

Re: Error using Transacted with Camel 2.0

by Claus Ibsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jul 3, 2009 at 4:44 PM, Charles Moulliard<cmoulliard@...> wrote:

> If I use as TransactionManager
>
> org.springframework.orm.hibernate3.HibernateTransactionManager
>
> in DAO layer
> in Spring layer
> in Camel route
>
> instead of
>
> org.springframework.transaction.PlatformTransactionManager
>
> It works. The transaction is well rollbacked !!!!! yes yes yes yes
Ah yeah it is. Since the DB TX manager will handle the DB and since
you are consuming from a JMS queue then Spring
DefaultMessageListenerContainer will also rollback if a *runtime*
exception is thrown back to it. And Camel does this in its
TransactionErrorHandler. So yeah you are safe now.

Only problem is if you also want to send a JMS message in your route :)



>
> If you find a solution to use the JTATransactionManager Guillaume, you are
> welcome ;-)
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jul 3, 2009 at 4:14 PM, Charles Moulliard <cmoulliard@...>wrote:
>
>> OK. I will change my config to use a separate TransactionManager for DB
>> stuffs.
>>
>> My idea was to use the same transaction manager (JTA) in the application
>> for JMS, DB, ... transactions but If this is not possible ...
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...> wrote:
>>
>>> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...>
>>> wrote:
>>> > No. In the route presented here I don't make 2 independant DB calls.
>>> Only
>>> > one. The second bean called (generateError) only do a throw (without any
>>> > Hibernate/DB call)
>>> >
>>> > By the way, in the example
>>> >
>>> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
>>> > two DB calls are made by two different beans and rollback is done !!
>>> Yes and it is because it uses a DB TX manager
>>>
>>>    <!-- spring transaction manager -->
>>>    <bean id="txManager"
>>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>>>        <property name="dataSource" ref="dataSource"/>
>>>    </bean>
>>>
>>> This TX manager knows about DB stuff.
>>>
>>>
>>>
>>>
>>> >
>>> > Regards,
>>> >
>>> > Charles Moulliard
>>> > Senior Enterprise Architect
>>> > Apache Camel Committer
>>> >
>>> > *****************************
>>> > blog : http://cmoulliard.blogspot.com
>>> >
>>> >
>>> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
>>> wrote:
>>> >
>>> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
>>> 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<cmoulliard@...
>>> >
>>> >> 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 <claus.ibsen@...
>>> >
>>> >> wrote:
>>> >> >>
>>> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<gnodet@...>
>>> >> 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<
>>> cmoulliard@...
>>> >> >
>>> >> >>> 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 <
>>> claus.ibsen@...
>>> >> >
>>> >> >>> 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<
>>> claus.ibsen@...
>>> >> >
>>> >> >>> 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<
>>> >> >>> cmoulliard@...>
>>> >> >>> >>> 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 <
>>> >> >>> cmoulliard@...
>>> >> >>> >>> >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 <
>>> >> claus.ibsen@...
>>> >> >>> >
>>> >> >>> >>> wrote:
>>> >> >>> >>> >>>
>>> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>>> >> >>> >>> cmoulliard@...>
>>> >> >>> >>> >>>> 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.ibsen@...>
>>> >> >>> >>> >>>> 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<
>>> >> >>> >>> cmoulliard@...
>>> >> >>> >>> >>>> >
>>> >> >>> >>> >>>> >> 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 <
>>> >> >>> >>> >>>> cmoulliard@...
>>> >> >>> >>> >>>> >> >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.ibsen@...>
>>> >> >>> >>> >>>> >> wrote:
>>> >> >>> >>> >>>> >> >>
>>> >> >>> >>> >>>> >> >>> Hi
>>> >> >>> >>> >>>> >> >>>
>>> >> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction
>>> stuff.
>>> >> >>> >>> >>>> >> >>>
>>> >> >>> >>> >>>> >> >>>
>>> >> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>>> >> >>> >>> >>>> cmoulliard@...
>>> >> >>> >>> >>>> >> >
>>> >> >>> >>> >>>> >> >>> 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
>>> >>
>>> >
>>>
>>>
>>>
>>> --
>>> 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

Re: Error using Transacted with Camel 2.0

by cmoulliard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For the moment, I don't generate/send a message in the route.

Nevertheless, like we do top of a classical ApplicationServer (WebSphere,
...), it should be interesting to use only one TransactionManager (like
Geronimo Tx) and not the one created by Spring for DB stuff, another for JMS
and so on. That was my philosophy since the beginning of this project.

I will have a look to the TransactionErrorHandler to see if we can change
something to work with both kind of implementations (local or global).

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

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


On Fri, Jul 3, 2009 at 5:20 PM, Claus Ibsen <claus.ibsen@...> wrote:

> On Fri, Jul 3, 2009 at 4:44 PM, Charles Moulliard<cmoulliard@...>
> wrote:
> > If I use as TransactionManager
> >
> > org.springframework.orm.hibernate3.HibernateTransactionManager
> >
> > in DAO layer
> > in Spring layer
> > in Camel route
> >
> > instead of
> >
> > org.springframework.transaction.PlatformTransactionManager
> >
> > It works. The transaction is well rollbacked !!!!! yes yes yes yes
> Ah yeah it is. Since the DB TX manager will handle the DB and since
> you are consuming from a JMS queue then Spring
> DefaultMessageListenerContainer will also rollback if a *runtime*
> exception is thrown back to it. And Camel does this in its
> TransactionErrorHandler. So yeah you are safe now.
>
> Only problem is if you also want to send a JMS message in your route :)
>
>
>
> >
> > If you find a solution to use the JTATransactionManager Guillaume, you
> are
> > welcome ;-)
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jul 3, 2009 at 4:14 PM, Charles Moulliard <cmoulliard@...
> >wrote:
> >
> >> OK. I will change my config to use a separate TransactionManager for DB
> >> stuffs.
> >>
> >> My idea was to use the same transaction manager (JTA) in the application
> >> for JMS, DB, ... transactions but If this is not possible ...
> >>
> >> Regards,
> >>
> >> Charles Moulliard
> >> Senior Enterprise Architect
> >> Apache Camel Committer
> >>
> >> *****************************
> >> blog : http://cmoulliard.blogspot.com
> >>
> >>
> >> On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...>
> wrote:
> >>
> >>> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...
> >
> >>> wrote:
> >>> > No. In the route presented here I don't make 2 independant DB calls.
> >>> Only
> >>> > one. The second bean called (generateError) only do a throw (without
> any
> >>> > Hibernate/DB call)
> >>> >
> >>> > By the way, in the example
> >>> >
> >>>
> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
> >>> > two DB calls are made by two different beans and rollback is done !!
> >>> Yes and it is because it uses a DB TX manager
> >>>
> >>>    <!-- spring transaction manager -->
> >>>    <bean id="txManager"
> >>>
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> >>>        <property name="dataSource" ref="dataSource"/>
> >>>    </bean>
> >>>
> >>> This TX manager knows about DB stuff.
> >>>
> >>>
> >>>
> >>>
> >>> >
> >>> > Regards,
> >>> >
> >>> > Charles Moulliard
> >>> > Senior Enterprise Architect
> >>> > Apache Camel Committer
> >>> >
> >>> > *****************************
> >>> > blog : http://cmoulliard.blogspot.com
> >>> >
> >>> >
> >>> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
> >>> wrote:
> >>> >
> >>> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
> >>> 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<
> cmoulliard@...
> >>> >
> >>> >> 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 <
> claus.ibsen@...
> >>> >
> >>> >> wrote:
> >>> >> >>
> >>> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<
> gnodet@...>
> >>> >> 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<
> >>> cmoulliard@...
> >>> >> >
> >>> >> >>> 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 <
> >>> claus.ibsen@...
> >>> >> >
> >>> >> >>> 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<
> >>> claus.ibsen@...
> >>> >> >
> >>> >> >>> 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<
> >>> >> >>> cmoulliard@...>
> >>> >> >>> >>> 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 <
> >>> >> >>> cmoulliard@...
> >>> >> >>> >>> >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 <
> >>> >> claus.ibsen@...
> >>> >> >>> >
> >>> >> >>> >>> wrote:
> >>> >> >>> >>> >>>
> >>> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> >>> >> >>> >>> cmoulliard@...>
> >>> >> >>> >>> >>>> 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.ibsen@...>
> >>> >> >>> >>> >>>> 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<
> >>> >> >>> >>> cmoulliard@...
> >>> >> >>> >>> >>>> >
> >>> >> >>> >>> >>>> >> 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
> <
> >>> >> >>> >>> >>>> cmoulliard@...
> >>> >> >>> >>> >>>> >> >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.ibsen@...>
> >>> >> >>> >>> >>>> >> wrote:
> >>> >> >>> >>> >>>> >> >>
> >>> >> >>> >>> >>>> >> >>> Hi
> >>> >> >>> >>> >>>> >> >>>
> >>> >> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction
> >>> stuff.
> >>> >> >>> >>> >>>> >> >>>
> >>> >> >>> >>> >>>> >> >>>
> >>> >> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles
> Moulliard<
> >>> >> >>> >>> >>>> cmoulliard@...
> >>> >> >>> >>> >>>> >> >
> >>> >> >>> >>> >>>> >> >>> 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
> >>> >>
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> 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
>
Charles Moulliard
SOA Architect

My Blog : http://cmoulliard.blogspot.com/ 

Re: Error using Transacted with Camel 2.0

by gnodet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Right, but you must be prepared to have duplicate JMS messages if
something wrong happen between the time the data has been written to
the DB and the time the JMS message is acked.

On Fri, Jul 3, 2009 at 17:20, Claus Ibsen<claus.ibsen@...> wrote:

> On Fri, Jul 3, 2009 at 4:44 PM, Charles Moulliard<cmoulliard@...> wrote:
>> If I use as TransactionManager
>>
>> org.springframework.orm.hibernate3.HibernateTransactionManager
>>
>> in DAO layer
>> in Spring layer
>> in Camel route
>>
>> instead of
>>
>> org.springframework.transaction.PlatformTransactionManager
>>
>> It works. The transaction is well rollbacked !!!!! yes yes yes yes
> Ah yeah it is. Since the DB TX manager will handle the DB and since
> you are consuming from a JMS queue then Spring
> DefaultMessageListenerContainer will also rollback if a *runtime*
> exception is thrown back to it. And Camel does this in its
> TransactionErrorHandler. So yeah you are safe now.
>
> Only problem is if you also want to send a JMS message in your route :)
>
>
>
>>
>> If you find a solution to use the JTATransactionManager Guillaume, you are
>> welcome ;-)
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Fri, Jul 3, 2009 at 4:14 PM, Charles Moulliard <cmoulliard@...>wrote:
>>
>>> OK. I will change my config to use a separate TransactionManager for DB
>>> stuffs.
>>>
>>> My idea was to use the same transaction manager (JTA) in the application
>>> for JMS, DB, ... transactions but If this is not possible ...
>>>
>>> Regards,
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>>
>>>
>>> On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...> wrote:
>>>
>>>> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<cmoulliard@...>
>>>> wrote:
>>>> > No. In the route presented here I don't make 2 independant DB calls.
>>>> Only
>>>> > one. The second bean called (generateError) only do a throw (without any
>>>> > Hibernate/DB call)
>>>> >
>>>> > By the way, in the example
>>>> >
>>>> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
>>>> > two DB calls are made by two different beans and rollback is done !!
>>>> Yes and it is because it uses a DB TX manager
>>>>
>>>>    <!-- spring transaction manager -->
>>>>    <bean id="txManager"
>>>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>>>>        <property name="dataSource" ref="dataSource"/>
>>>>    </bean>
>>>>
>>>> This TX manager knows about DB stuff.
>>>>
>>>>
>>>>
>>>>
>>>> >
>>>> > Regards,
>>>> >
>>>> > Charles Moulliard
>>>> > Senior Enterprise Architect
>>>> > Apache Camel Committer
>>>> >
>>>> > *****************************
>>>> > blog : http://cmoulliard.blogspot.com
>>>> >
>>>> >
>>>> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
>>>> wrote:
>>>> >
>>>> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
>>>> 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<cmoulliard@...
>>>> >
>>>> >> 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 <claus.ibsen@...
>>>> >
>>>> >> wrote:
>>>> >> >>
>>>> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<gnodet@...>
>>>> >> 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<
>>>> cmoulliard@...
>>>> >> >
>>>> >> >>> 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 <
>>>> claus.ibsen@...
>>>> >> >
>>>> >> >>> 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<
>>>> claus.ibsen@...
>>>> >> >
>>>> >> >>> 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<
>>>> >> >>> cmoulliard@...>
>>>> >> >>> >>> 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 <
>>>> >> >>> cmoulliard@...
>>>> >> >>> >>> >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 <
>>>> >> claus.ibsen@...
>>>> >> >>> >
>>>> >> >>> >>> wrote:
>>>> >> >>> >>> >>>
>>>> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
>>>> >> >>> >>> cmoulliard@...>
>>>> >> >>> >>> >>>> 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.ibsen@...>
>>>> >> >>> >>> >>>> 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<
>>>> >> >>> >>> cmoulliard@...
>>>> >> >>> >>> >>>> >
>>>> >> >>> >>> >>>> >> 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 <
>>>> >> >>> >>> >>>> cmoulliard@...
>>>> >> >>> >>> >>>> >> >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.ibsen@...>
>>>> >> >>> >>> >>>> >> wrote:
>>>> >> >>> >>> >>>> >> >>
>>>> >> >>> >>> >>>> >> >>> Hi
>>>> >> >>> >>> >>>> >> >>>
>>>> >> >>> >>> >>>> >> >>> Yeah you need to add all the spring transaction
>>>> stuff.
>>>> >> >>> >>> >>>> >> >>>
>>>> >> >>> >>> >>>> >> >>>
>>>> >> >>> >>> >>>> >> >>> On Thu, Jul 2, 2009 at 3:47 PM, Charles Moulliard<
>>>> >> >>> >>> >>>> cmoulliard@...
>>>> >> >>> >>> >>>> >> >
>>>> >> >>> >>> >>>> >> >>> 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
>>>> >>
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> 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

Re: Error using Transacted with Camel 2.0

by cmoulliard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I don't know If I'm wrong or not but I try to configure only
spring/hibernate with Geronimo Transaction Manager in Apache Felix Karaf but
it does not work. Here is the config.

1) Hibernate / Spring / Geronimo

A) Hibernate / Spring config

<!--  Hibernate SessionFactory Definition -->
    <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.manager_lookup_class">org.springframework.orm.hibernate3.LocalTransactionManagerLookup</prop>
            </props>
        </property>
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <!-- lookup to the jtaTxManager bean to find Geronimo Transaction
Manager -->
        <property name="jtaTransactionManager">
             <bean factory-bean="jtaTxManager"
factory-method="getTransactionManager"/>
        </property>
    </bean>

    <!-- JTA Transaction Manager lookup -->
    <bean id="jtaTxManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
      <property name="transactionManager">
          <osgi:reference interface="javax.transaction.TransactionManager"/>
        </property>
    </bean>

    <!-- JTA Transaction Manager exported as OSGI service -->
    <osgi:service id="transactionManagerOsgi" ref="jtaTxManager">
        <osgi:interfaces>

<value>org.springframework.transaction.PlatformTransactionManager</value>

<value>org.springframework.transaction.jta.JtaTransactionManager</value>
        </osgi:interfaces>
    </osgi:service>

B) Services

    <bean id="abstractService" abstract="true"

class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager">
            <osgi:reference>
                <osgi:interfaces>
                    <!--
<value>org.springframework.orm.hibernate3.HibernateTransactionManager</value>
-->

<value>org.springframework.transaction.PlatformTransactionManager</value>

<value>org.springframework.transaction.jta.JtaTransactionManager</value>
                </osgi:interfaces>
            </osgi:reference>
        </property>
    </bean>

Remark : Apache ActiveMq Camel component is not longer transacted

2) Camel route

Remark : Transacted has been removed from the route so we call a bean which
is a spring service plumbing Hibernate stuffs

Here is what I see in the log :

09:41:31,528 | DEBUG | 0: FileComponent | nager$$EnhancerByCGLIB$$4cb40106 |
stractPlatformTransactionManager  371 | Creating new transaction with name
[com.xpectis.x3s.platform.service.RequestService.saveRequest]:
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
09:41:31,544 | DEBUG | 0: FileComponent | SessionFactoryUtils              |
m.hibernate3.SessionFactoryUtils  318 | Opening Hibernate Session
09:41:31,606 | DEBUG | 0: FileComponent | SessionImpl                      |
org.hibernate.impl.SessionImpl    247 | opened session at timestamp:
12469524915
09:41:31,606 | DEBUG | 0: FileComponent | SessionFactoryUtils              |
m.hibernate3.SessionFactoryUtils  326 | Registering Spring transaction
synchronization for new Hibernate Session
09:41:32,763 | DEBUG | 0: FileComponent | SessionFactoryUtils              |
m.hibernate3.SessionFactoryUtils  789 | Closing Hibernate Session
09:41:32,763 | DEBUG | 0: FileComponent | nager$$EnhancerByCGLIB$$4cb40106 |
stractPlatformTransactionManager  821 | Initiating transaction rollback

No insert is done in the DB


Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

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


On Fri, Jul 3, 2009 at 5:33 PM, Guillaume Nodet <gnodet@...> wrote:

> Right, but you must be prepared to have duplicate JMS messages if
> something wrong happen between the time the data has been written to
> the DB and the time the JMS message is acked.
>
> On Fri, Jul 3, 2009 at 17:20, Claus Ibsen<claus.ibsen@...> wrote:
> > On Fri, Jul 3, 2009 at 4:44 PM, Charles Moulliard<cmoulliard@...>
> wrote:
> >> If I use as TransactionManager
> >>
> >> org.springframework.orm.hibernate3.HibernateTransactionManager
> >>
> >> in DAO layer
> >> in Spring layer
> >> in Camel route
> >>
> >> instead of
> >>
> >> org.springframework.transaction.PlatformTransactionManager
> >>
> >> It works. The transaction is well rollbacked !!!!! yes yes yes yes
> > Ah yeah it is. Since the DB TX manager will handle the DB and since
> > you are consuming from a JMS queue then Spring
> > DefaultMessageListenerContainer will also rollback if a *runtime*
> > exception is thrown back to it. And Camel does this in its
> > TransactionErrorHandler. So yeah you are safe now.
> >
> > Only problem is if you also want to send a JMS message in your route :)
> >
> >
> >
> >>
> >> If you find a solution to use the JTATransactionManager Guillaume, you
> are
> >> welcome ;-)
> >>
> >> Charles Moulliard
> >> Senior Enterprise Architect
> >> Apache Camel Committer
> >>
> >> *****************************
> >> blog : http://cmoulliard.blogspot.com
> >>
> >>
> >> On Fri, Jul 3, 2009 at 4:14 PM, Charles Moulliard <cmoulliard@...
> >wrote:
> >>
> >>> OK. I will change my config to use a separate TransactionManager for DB
> >>> stuffs.
> >>>
> >>> My idea was to use the same transaction manager (JTA) in the
> application
> >>> for JMS, DB, ... transactions but If this is not possible ...
> >>>
> >>> Regards,
> >>>
> >>> Charles Moulliard
> >>> Senior Enterprise Architect
> >>> Apache Camel Committer
> >>>
> >>> *****************************
> >>> blog : http://cmoulliard.blogspot.com
> >>>
> >>>
> >>> On Fri, Jul 3, 2009 at 4:08 PM, Claus Ibsen <claus.ibsen@...>
> wrote:
> >>>
> >>>> On Fri, Jul 3, 2009 at 4:04 PM, Charles Moulliard<
> cmoulliard@...>
> >>>> wrote:
> >>>> > No. In the route presented here I don't make 2 independant DB calls.
> >>>> Only
> >>>> > one. The second bean called (generateError) only do a throw (without
> any
> >>>> > Hibernate/DB call)
> >>>> >
> >>>> > By the way, in the example
> >>>> >
> >>>>
> apache-camel-source\components\camel-spring\src\test\java\org\apache\camel\spring\interceptor\TransactionalClientDataSourceTest.java,
> >>>> > two DB calls are made by two different beans and rollback is done !!
> >>>> Yes and it is because it uses a DB TX manager
> >>>>
> >>>>    <!-- spring transaction manager -->
> >>>>    <bean id="txManager"
> >>>>
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> >>>>        <property name="dataSource" ref="dataSource"/>
> >>>>    </bean>
> >>>>
> >>>> This TX manager knows about DB stuff.
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> >
> >>>> > Regards,
> >>>> >
> >>>> > Charles Moulliard
> >>>> > Senior Enterprise Architect
> >>>> > Apache Camel Committer
> >>>> >
> >>>> > *****************************
> >>>> > blog : http://cmoulliard.blogspot.com
> >>>> >
> >>>> >
> >>>> > On Fri, Jul 3, 2009 at 3:56 PM, Claus Ibsen <claus.ibsen@...>
> >>>> wrote:
> >>>> >
> >>>> >> On Fri, Jul 3, 2009 at 3:52 PM, Guillaume Nodet<gnodet@...>
> >>>> 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<
> cmoulliard@...
> >>>> >
> >>>> >> 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 <
> claus.ibsen@...
> >>>> >
> >>>> >> wrote:
> >>>> >> >>
> >>>> >> >>> On Fri, Jul 3, 2009 at 12:16 PM, Guillaume Nodet<
> gnodet@...>
> >>>> >> 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<
> >>>> cmoulliard@...
> >>>> >> >
> >>>> >> >>> 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 <
> >>>> claus.ibsen@...
> >>>> >> >
> >>>> >> >>> 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<
> >>>> claus.ibsen@...
> >>>> >> >
> >>>> >> >>> 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<
> >>>> >> >>> cmoulliard@...>
> >>>> >> >>> >>> 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 <
> >>>> >> >>> cmoulliard@...
> >>>> >> >>> >>> >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 <
> >>>> >> claus.ibsen@...
> >>>> >> >>> >
> >>>> >> >>> >>> wrote:
> >>>> >> >>> >>> >>>
> >>>> >> >>> >>> >>>> On Thu, Jul 2, 2009 at 4:53 PM, Charles Moulliard<
> >>>> >> >>> >>> cmoulliard@...>
> >>>> >> >>> >>> >>>> 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.ibsen@...>
> >>>> >> >>> >>> >>>> 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<
> >>>> >> >>> >>> cmoulliard@...
> >>>> >> >>> >>> >>>> >
> >>>> >> >>> >>> >>>> >> 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
> >>>> >> >>> >>> &g