Hi
I did that too:
<camel:camelContext id="camel">
<camel:route>
<camel:from
uri="oracle:queue:java:comp/resource/WeborderJmsResourceProvider/Queues/JMSEXAMPLE?maxMessagesPerTask=-1"
/>
<camel:policy ref="PROPAGATION_REQUIRED"/>
<camel:to uri="bean:testProcessor" />
<camel:to uri="bean:updateProcessor" />
</camel:route>
</camel:camelContext>
<bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="transactionManager"/>
</bean>
Claus Ibsen-2 wrote:
>
> Hi
>
> You need to set transacted=true on the JMS endpoint to let it be
> transacted.
> Try this first as you use annotations for the rest so that might do the
> trick.
>
> If not you need to add <policy ref="required"/> in the route so Camel
> knows its a transacted route.
>
> See more here:
> http://camel.apache.org/transactional-client.html
>
>
>
>
>
>
> On Tue, Aug 4, 2009 at 9:55 AM,
> smilicevics<[email protected]> wrote:
>>
>> Hi,
>>
>> I am using apache camel 1.6.1, oracle as 10.1.3.3, spring 2.5., aspectj
>> 1.5.4
>> Here is the stacktrace:
>>
>> 1817082 2009-08-03 17:20:33,623 DEBUG
>> org.apache.camel.component.jms.EndpointMessageListener.onMessage(63) -
>> Endpoint[oracle:queue:java:comp/resource/WeborderJmsResourceProvider/Queues/JMSEXAMPLE?maxMessagesPerTask=-1]
>> consumer receiving JMS message: oracle.jms.aqjmstextmess...@74e259
>> 1817082 2009-08-03 17:20:33,623 DEBUG
>> org.apache.camel.impl.converter.DefaultTypeConverter.doConvertTo(96) -
>> Converting null -> java.lang.Boolean with value: null
>> 1817082 2009-08-03 17:20:33,623 DEBUG
>> org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(469)
>> - Participating in existing transaction
>> 1817082 2009-08-03 17:20:33,623 DEBUG
>> org.apache.camel.spring.spi.TransactionInterceptor$1.doInTransactionWithoutResult(101)
>> - Is actual transaction active: true
>> 1817082 2009-08-03 17:20:33,623 DEBUG
>> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(214)
>> - Returning cached instance of singleton bean 'testProcessor'
>> 1817097 2009-08-03 17:20:33,638 DEBUG
>> org.springframework.jdbc.core.JdbcTemplate.execute(417) - Executing SQL
>> statement [insert into test values ('this is only test')]
>> 1817097 2009-08-03 17:20:33,638 DEBUG
>> org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(112)
>> -
>> Fetching JDBC Connection from DataSource
>> 1817097 2009-08-03 17:20:33,638 DEBUG
>> org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(116)
>> -
>> Registering transaction synchronization for JDBC Connection
>> 1817097 2009-08-03 17:20:33,638 DEBUG
>> org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(186)
>> - Bound value
>> [org.springframework.jdbc.datasource.connectionhol...@d8b0f6]
>> for key [oracle.oc4j.sql.manageddatasou...@5cba16] to thread
>> [DefaultMessageListenerContainer-7]
>> 1817097 2009-08-03 17:20:33,638 DEBUG
>> org.springframework.transaction.support.TransactionSynchronizationManager.getResource(142)
>> - Retrieved value
>> [org.springframework.jdbc.datasource.connectionhol...@d8b0f6] for key
>> [oracle.oc4j.sql.manageddatasou...@5cba16] bound to thread
>> [DefaultMessageListenerContainer-7]
>> 1817113 2009-08-03 17:20:33,654 DEBUG
>> org.springframework.transaction.support.TransactionSynchronizationManager.getResource(142)
>> - Retrieved value
>> [org.springframework.jdbc.datasource.connectionhol...@d8b0f6] for key
>> [oracle.oc4j.sql.manageddatasou...@5cba16] bound to thread
>> [DefaultMessageListenerContainer-7]
>> 1817113 2009-08-03 17:20:33,654 DEBUG
>> org.springframework.transaction.support.TransactionSynchronizationManager.getResource(142)
>> - Retrieved value
>> [org.springframework.jms.listener.locallyexposedjmsresourcehol...@13223ad]
>> for key [oracle.jms.aqjmsqueueconnectionfact...@130fa43] bound to thread
>> [DefaultMessageListenerContainer-7]
>> 1817113 2009-08-03 17:20:33,654 DEBUG
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(328)
>> - Rolling back transaction because of listener exception thrown:
>> oracle.jms.AQjmsException: Die Methode 'commit' kann nicht aufgerufen
>> werden, wenn eine globale Transaktion aktiv ist.
>> 1817113 2009-08-03 17:20:33,654 WARN
>> org.springframework.jms.listener.AbstractMessageListenerContainer.handleListenerException(646)
>> - Execution of JMS message listener failed
>> oracle.jms.AQjmsException: Die Methode 'commit' kann nicht aufgerufen
>> werden, wenn eine globale Transaktion aktiv ist.
>> at oracle.jms.AQjmsSession.commitNoCheck(AQjmsSession.java:815)
>> at oracle.jms.AQjmsSession.commit(AQjmsSession.java:784)
>> at
>> org.springframework.jms.support.JmsUtils.commitIfNecessary(JmsUtils.java:217)
>> at
>> org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:558)
>> at
>> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:465)
>> at
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>> at
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
>> at java.lang.Thread.run(Thread.java:595)
>>
>> [Linked-exception]
>> java.sql.SQLException: Die Methode 'commit' kann nicht aufgerufen werden,
>> wenn eine globale Transaktion aktiv ist.
>> at
>> oracle.oc4j.sql.spi.ConnectionHandle.oc4j_throwSQLExceptionIfGlobalTxActive(ConnectionHandle.java:417)
>> at
>> oracle.oc4j.sql.spi.ConnectionHandle.commit(ConnectionHandle.java:123)
>> at oracle.jms.AQjmsSession.commitNoCheck(AQjmsSession.java:811)
>> at oracle.jms.AQjmsSession.commit(AQjmsSession.java:784)
>> at
>> org.springframework.jms.support.JmsUtils.commitIfNecessary(JmsUtils.java:217)
>> at
>> org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:558)
>> at
>> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:465)
>> at
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>> at
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
>> at java.lang.Thread.run(Thread.java:595)
>>
>> The error message is in german, but you can guess what it means "Cannot
>> call
>> commit in a global transaction".
>>
>> I did already looked in google, and did not find it.
>> As you suggested I will try to find some working example with oc4j spring
>> jdbc and xa.
>>
>> thx,
>> Sasa
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> Which versions of the various products are you using?
>>>
>>> And when you get an error shown the real stacktrace / error message
>>> helps.
>>>
>>> And try use google on this exception / stacktrace to find others with
>>> same problem.
>>>
>>> And try get a sample working with Oracle + Spring + JDBC + XA to
>>> ensure that combo works before throwing in annotations, aop and other
>>> stuff that just complicates matter.
>>>
>>> And there was an issue in Camel 1.6.0 or older with sometimes Spring
>>> did not do IoC on classes with @annotations. It did output something
>>> about bean XXX not being eligible for ... So check whether Spring
>>> logs this in your case.
>>>
>>>
>>> On Mon, Aug 3, 2009 at 5:57 PM,
>>> smilicevics<[email protected]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am trying to write code which will consume a message and do the
>>>> insert
>>>> in
>>>> database.
>>>> I want to use global transactions and two-phase-commit.
>>>>
>>>> I got always the same error: cannot commit in global transaction.
>>>> Can somebody tell me what am i doing wrong here:
>>>>
>>>> this is my spring xml:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>
>>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xmlns:camel="http://activemq.apache.org/camel/schema/spring"
>>>> xmlns:tx="http://www.springframework.org/schema/tx"
>>>> xmlns:aop="http://www.springframework.org/schema/aop"
>>>> xsi:schemaLocation="
>>>> http://www.springframework.org/schema/beans
>>>> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>>>> http://activemq.apache.org/camel/schema/spring camel-spring.xsd
>>>> http://www.springframework.org/schema/tx
>>>> http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
>>>> http://www.springframework.org/schema/aop
>>>> http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
>>>>
>>>>
>>>> <camel:camelContext id="camel">
>>>> <camel:route>
>>>> <camel:from
>>>> uri="oracle:queue:java:comp/resource/WeborderJmsResourceProvider/Queues/JMSEXAMPLE?maxMessagesPerTask=-1"
>>>> />
>>>> <camel:to uri="bean:testProcessor" />
>>>> </camel:route>
>>>> </camel:camelContext>
>>>>
>>>> <camel:template id="camelTemplate" />
>>>>
>>>> <bean id="oracle"
>>>> class="org.apache.camel.component.jms.JmsComponent">
>>>> <property name="connectionFactory"
>>>> ref="oJmsQueueConnectionFactory" />
>>>> <property name="destinationResolver"
>>>> ref="jmsDestinationResolver" />
>>>> <property name="transacted" value="true" />
>>>> <property name="transactionManager"
>>>> ref="transactionManager" />
>>>> </bean>
>>>>
>>>> <bean id="jmsDestinationResolver"
>>>>
>>>> class="org.springframework.jms.support.destination.JndiDestinationResolver">
>>>> <property name="jndiTemplate" ref="jndiTemplate" />
>>>> <property name="cache" value="true" />
>>>> </bean>
>>>>
>>>> <bean id="transactionManager"
>>>> class="org.springframework.transaction.jta.OC4JJtaTransactionManager"
>>>> />
>>>>
>>>> <bean id="oJmsQueueConnectionFactory"
>>>> class="org.springframework.jndi.JndiObjectFactoryBean">
>>>> <property name="jndiTemplate" ref="jndiTemplate" />
>>>> <property name="jndiName">
>>>>
>>>> <value>java:comp/resource/WeborderJmsResourceProvider/QueueConnectionFactories/QCF</value>
>>>> </property>
>>>> </bean>
>>>>
>>>> <bean id="jndiTemplate"
>>>> class="org.springframework.jndi.JndiTemplate" />
>>>>
>>>> <bean id="testProcessor" class="oc4j.test.TestProcessor">
>>>> <property name="testImpl" ref="testImpl" />
>>>> </bean>
>>>>
>>>> <bean id="testDataSource"
>>>> class="org.springframework.jndi.JndiObjectFactoryBean">
>>>> <property name="jndiName" value="jdbc/WeborderJmsDS" />
>>>> </bean>
>>>>
>>>> <bean id="testImpl" class="oc4j.test.TestImpl">
>>>> <property name="dataSource" ref="testDataSource" />
>>>> </bean>
>>>>
>>>> <aop:config>
>>>> <aop:pointcut id="process" expression="execution(*
>>>> oc4j.test.*)"/>
>>>> <aop:advisor pointcut-ref="process"
>>>> advice-ref="txAdvice"/>
>>>> </aop:config>
>>>>
>>>> <tx:advice id="txAdvice"
>>>> transaction-manager="transactionManager">
>>>> <tx:attributes>
>>>> <tx:method name="process"
>>>> propagation="REQUIRED"/>
>>>> </tx:attributes>
>>>> </tx:advice>
>>>>
>>>> </beans>
>>>>
>>>> and TestProcessor:
>>>>
>>>> public class TestProcessor implements Processor {
>>>>
>>>> private TestImpl test = null;
>>>>
>>>> public void setTestImpl(TestImpl test) {
>>>> this.test = test;
>>>> }
>>>>
>>>> �...@transactional(propagation = Propagation.REQUIRED)
>>>> public void process(Exchange arg0) throws Exception {
>>>>
>>>> Logger logger = Logger
>>>>
>>>> .getLogger("oc4j.test.Oc4jServletContextListener");
>>>>
>>>> test.insertTest();
>>>> logger.info("Received exchange: " + arg0.getIn());
>>>> logger.info("Received exchange: " +
>>>> arg0.getIn().getBody());
>>>> }
>>>> }
>>>>
>>>> and TestImpl:
>>>>
>>>> public class TestImpl extends JdbcDaoSupport {
>>>>
>>>> public void insertTest() {
>>>> getJdbcTemplate().execute("insert into test values
>>>> ('this
>>>> is only
>>>> test')");
>>>> }
>>>> }
>>>>
>>>>
>>>> thanks in advance.
>>>>
>>>> Sasa
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Two-Phase-Commit-with-JCA%2C-Spring%2C-Camel-and-OC4j-tp24793274p24793274.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Two-Phase-Commit-with-JCA%2C-Spring%2C-Camel-and-OC4j-tp24793274p24803834.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
>
--
View this message in context:
http://www.nabble.com/Two-Phase-Commit-with-JCA%2C-Spring%2C-Camel-and-OC4j-tp24793274p24805711.html
Sent from the Camel - Users mailing list archive at Nabble.com.