0
votes

In mule flow, am unable to run JDBC transactions while using Flow-Ref. The same transactional scope works, if no flow-ref is used.

any ideas ?

Here is my configuration xml.

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
    <spring:beans>
        <spring:bean id="JdbcBean1" name="JdbcBean1" class="oracle.jdbc.xa.client.OracleXADataSource">
            <spring:property name="user" value="${sample.db.user}"/>
            <spring:property name="URL" value="jdbc:oracle:thin:@//${sample.db.host.name}:1521/${sample.db.instance.name}"/>
            <spring:property name="password" value="${sample.db.password}"/>
        </spring:bean>
    </spring:beans>
    <jbossts:transaction-manager doc:name="Transaction Manager"/>
    <jdbc-ee:connector name="Database" dataSource-ref="JdbcBean1" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
    <flow name="jdbctransactionFlow1" doc:name="jdbctransactionFlow1">
        <file:inbound-endpoint path="src/test/resources/input" moveToDirectory="src/test/resources/output" responseTimeout="10000" doc:name="File"/>
        <file:file-to-string-transformer doc:name="File to String"/>
        <flow-ref name="jdbctransactionFlow2" doc:name="Flow Reference"/>
        <file:outbound-endpoint path="src/test/resources/outputResult" outputPattern="output.xml" responseTimeout="10000" doc:name="File"/>
    </flow>
    <flow name="jdbctransactionFlow2" doc:name="jdbctransactionFlow2">
        <logger message="xa start" level="INFO" doc:name="Logger"/>
        <transactional action="BEGIN_OR_JOIN" doc:name="Transactional">
            <jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="updateTPCCounterType_TPC410" queryTimeout="-1" connector-ref="Database" doc:name="Database">
                <jdbc-ee:transaction action="ALWAYS_JOIN"/>
                <jdbc-ee:query key="updateTPCCounterType_TPC410" value="${sample.db.query.updateTPCCounterType_TPC}"/>
            </jdbc-ee:outbound-endpoint>
            <jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="insert_TPCM_POC_HEADER" queryTimeout="-1" connector-ref="Database" doc:name="Database">
                <jdbc-ee:transaction action="ALWAYS_JOIN"/>
                <jdbc-ee:query key="insert_TPCM_POC_HEADER" value="${sample.db.query.insert_TPCM_POC_HEADER}"/>
            </jdbc-ee:outbound-endpoint>
            <jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="insert_TPCM_POC_DETAIL" queryTimeout="-1" connector-ref="Database" doc:name="Database">
                <jdbc-ee:transaction action="ALWAYS_JOIN"/>
                <jdbc-ee:query key="insert_TPCM_POC_DETAIL" value="${sample.db.query.insert_TPCM_POC_DETAIL}"/>
            </jdbc-ee:outbound-endpoint>
        </transactional>
        <logger message="xa end" level="INFO" doc:name="Logger"/>
    </flow>
</mule>

The error I get:

ERROR 2013-11-22 19:07:45,781 [main] org.mule.module.launcher.application.DefaultMuleApplication: null org.mule.api.lifecycle.InitialisationException: Component has not been initialized properly, no flow constuct. ...

INFO 2013-11-22 19:07:45,783 [main] org.mule.module.launcher.application.DefaultMuleApplication: App 'Receiver' never started, nothing to dispose of Exception in thread "main" org.mule.module.launcher.DeploymentInitException: InitialisationException: Component has not been initialized properly, no flow constuct. ...

Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name 'testTranscationFlowFlow1': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Component has not been initialized properly, no flow constuct. ...

...

Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name 'testTranscationFlowFlow1': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Component has not been initialized properly, no flow constuct.Caused by: org.mule.api.lifecycle.InitialisationException: Error creating bean with name 'testTranscationFlowFlow1': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Component has not been initialized properly, no flow constuct. ...

1
The error trace shows a flow with the name 'testTranscationFlowFlow1' but could find that flow in the config provided in the post. Try verifying that flow for any issues. If possible add that config here so that it will help in solving the issue. - user1760178
@user1760178 is right: the issue is related to testTranscationFlowFlow1 not shown in your config... can't really help you... - David Dossot
Yes, my mistake,I have corrected the flow names and it worked. anyway Thank a lot. - user2944686

1 Answers

0
votes

Try the following for your flow 2

<flow name="jdbctransactionFlow2"
      processingStrategy="synchronous"
      doc:name="jdbctransactionFlow2">

The above solution is for the issue mentioned in the post that the Code works in single flow. But not working when tried using flow-ref.

Hope this helps.