So, which transaction manager would you give to the jms component?  The jms 
one?  Then the db inserts/updates would use the Aries transaction manager?  
I'll use your example project as a sandbox to play with this setup.  Thanks 
again!

On Sep 15, 2012, at 4:54 PM, Christian Müller <christian.muel...@gmail.com> 
wrote:

> You could use a "normal" JMS transaction to read your JMS message and write
> the response back into a queue (in the same transaction of course).
> Make sure your database inserts/updates are committed all together.
> If your database insert/update fails, the JMS transaction manager will
> rollback your transaction and the JMS message will be put back into your
> queue.
> If the insert/update was successful, the JMS transaction will be comitted
> which means the message you read will be deleted and the response message
> will be committed into the response queue.
> 
> There is a potential risks:
> - The database insert/update was successful and before you could commit the
> JMS transaction, the JMS broker went down. After restarting the broker, the
> message will be redelivered because of the missing commit. May be this is
> not a problem, if your database access is idempotent (if you execute an
> update or a stored procedure which checks for duplicated before it executes
> the insert or ...).
> 
> May be this link is also helpful for your:
> http://www.javaworld.com/javaworld/jw-01-2009/jw-01-spring-transactions.html
> 
> Best,
> Christian
> 
> On Fri, Sep 14, 2012 at 3:28 PM, James Carman 
> <ja...@carmanconsulting.com>wrote:
> 
>> Christian,
>> 
>> Also, what we're looking to do is use non-XA WebSphere MQ connections.
>> So, we need to figure out how to configure this stuff using non-XA
>> JMS, but still have it behave correctly.  We are using DBCP's
>> "managed" pool support for the data sources.  We believe that's
>> working okay.
>> 
>> Thanks,
>> 
>> James
>> 
>> On Thu, Sep 13, 2012 at 6:11 PM, Christian Müller
>> <christian.muel...@gmail.com> wrote:
>>> May be these examples are useful for you:
>>> https://github.com/muellerc/camel-in-transaction
>>> 
>>> Best,
>>> Christian
>>> 
>>> On Thu, Sep 13, 2012 at 4:33 PM, James Carman <
>> ja...@carmanconsulting.com>wrote:
>>> 
>>>> Claus,
>>>> 
>>>> Is there any guidance on how to set up XA correctly?  We're having a
>>>> really rough time getting Websphere MQ and SQL Server connections to
>>>> work together in an XA fashion.
>>>> 
>>>> Thanks,
>>>> 
>>>> james
>>>> 
>>>> On Thu, Sep 13, 2012 at 10:17 AM, Claus Ibsen <claus.ib...@gmail.com>
>>>> wrote:
>>>>> For that you would need XA when you have 2+ resources participating in
>>>>> the same transaction.
>>>>> It can be tricky to setup. You would need to use the JTA transaction
>>>>> manager from WebSphere etc which supports XA.
>>>>> 
>>>>> Make sure the MQ connection factory you refer to is the XA one.
>>>>> 
>>>>> On Thu, Sep 13, 2012 at 2:59 PM, Caa_man <c...@acs-it.ru> wrote:
>>>>>> Hello!
>>>>>> 
>>>>>> I`d like to built a camel route with this logic:
>>>>>> 
>>>>>>  - receive message with XML from WebSphere queue (camel "from")
>>>>>>  - begin transaction (distributed transaction via "transacted")
>>>>>>  - parse xml (camel "process")
>>>>>>  - save income message to Oracle DB (camel "process")
>>>>>>  - create reply message (camel "process")
>>>>>>  - send reply message to WebSphere queue (camel "to" with
>>>>>> uri="bean:mqRemoteSender?method=remoteRoute", where I manually send
>>>>>> camel-message body to MQQueue object)
>>>>>> 
>>>>>> i.e. I`d like to do "INSERT" request to DB and send message in single
>>>>>> transaction.
>>>>>> 
>>>>>> I use:
>>>>>> 
>>>>>> 1) JmsComponent:
>>>>>>  <bean id="wmq" class="org.apache.camel.component.jms.JmsComponent">
>>>>>>        <property name="connectionFactory"
>> ref="wmqConnectionFactory"/>
>>>>>>        <property name="concurrentConsumers" value="5"/>
>>>>>>        <property name="maxConcurrentConsumers" value="5"/>
>>>>>>        <property name="transactionManager"
>> ref="transactionManager"/>
>>>>>>        <property name="transacted" value="true"/>
>>>>>>  </bean>
>>>>>>  <bean id="wmqConnectionFactory"
>>>>>> class="com.ibm.mq.jms.MQConnectionFactory">
>>>>>>        <property name="transportType" value="1"/>
>>>>>>        <property name="hostName" value="${HostName}"/>
>>>>>>        <property name="port">
>>>>>>             <bean id="portValue" class="java.lang.Integer">
>>>>>>                 <constructor-arg value="${PortValue}"/>
>>>>>>             </bean>
>>>>>>        </property>
>>>>>>        <property name="queueManager" value="${ManagerName}"/>
>>>>>>        <property name="channel" value="${ConnectionChannel}"/>
>>>>>>  </bean>
>>>>>> 2) Transaction policy:
>>>>>>   <bean id="required"
>>>>>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>>>>>        <property name="transactionManager"
>> ref="transactionManager"/>
>>>>>>        <property name="propagationBehaviorName"
>>>>>> value="PROPAGATION_REQUIRED"/>
>>>>>>   </bean>
>>>>>> 3)  Transaction manager:
>>>>>>    <bean id="transactionManager"
>>>>>> class="org.springframework.transaction.jta.JtaTransactionManager"/>
>>>>>> 4)  Annotation driver:
>>>>>>   <tx:annotation-driven transaction-manager="transactionManager" />
>>>>>> 5) Process with DB save requests:
>>>>>> 
>>>>>>    private org.springframework.orm.jpa.JpaTemplate jtaTemplate;
>>>>>> 
>>>>>>    @Transactional(propagation = Propagation.REQUIRED)
>>>>>>    @Override
>>>>>>    public void process(Exchange exchange) throws Exception {
>>>>>>      SomeEntityClass entityObject = new SomeEntityClass();
>>>>>>     ...
>>>>>>      jtaTemplate.persist(entityObject);
>>>>>>      jtaTemplate.flush();
>>>>>>   }
>>>>>> 6) persistence-unit:
>>>>>>        <persistence-unit name="jpaName" transaction-type="JTA">
>>>>>> 
>>>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
>>>>>>        <jta-data-source>jdbc/applicationConnection</jta-data-source>
>>>>>>        <mapping-file>META-INF/orm.xml</mapping-file>
>>>>>>                <class>SomeEntityClass</class>
>>>>>>                <properties>
>>>>>>                        <property name="eclipselink.target-server"
>>>> value="OC4J" />
>>>>>>                        <property name="eclipselink.target-database"
>>>> value="Oracle" />
>>>>>>                        <property name="eclipselink.weaving"
>>>> value="false" />
>>>>>>                        <property name="eclipselink.logging.level"
>>>> value="FINE" />
>>>>>>                        <property
>>>> name="eclipselink.cache.shared.default" value="false"/>
>>>>>>            <property name="eclipselink.jdbc.batch-writing"
>>>>>> value="Oracle-JDBC" />
>>>>>>            <property name="eclipselink.jdbc.fetch-size"
>> value="1000" />
>>>>>>                </properties>
>>>>>>        </persistence-unit>
>>>>>> 
>>>>>> But there is no distributed transaction.
>>>>>> Oracle-db-transaction and wmq-send-transaction are independent from
>>>>>> jms-receive-transaction.
>>>>>> Whats wrong?
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> --
>>>>>> View this message in context:
>>>> 
>> http://camel.465427.n5.nabble.com/Distributed-transaction-in-camel-route-tp5719279.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Claus Ibsen
>>>>> -----------------
>>>>> FuseSource
>>>>> Email: cib...@fusesource.com
>>>>> Web: http://fusesource.com
>>>>> Twitter: davsclaus, fusenews
>>>>> Blog: http://davsclaus.com
>>>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>> 
>>> 
>>> 
>>> 
>>> --
>> 
> 
> 
> 
> --

Reply via email to