0
votes

I have Use Case as Below:

I have two flows in my Mule Project

Flow 1: a)Http as inbound endpoint.which is used to just trigger the flow. b) I have hornetq Jms configuration which push's the data to Q.

Flow 2: a)Jms with HortnerQ configuration as inbound which consumes the messages from the same Queue. b)After this i have Database as outbound endpoint. Here I am using SQL server for doing my Database operations.

When ever my database goes down or trying to insert data on to a non exisiting table retry mechanism should apply on the flow .

Done below changes : I have setted maxRedelievery=3 on my JMS connecter. Have added 3 in hornetq-configuration.xml file .Currently i am using hornetq2.0 version.

Tried some otherways like keep JMS transction with beginorjoin. No luck till on this. Please can some one help me on this situation.

Below is my configuration xml file.

<spring:beans>
    <spring:bean id="MSSQLDataSourceBean" name="MSSQLDataSourceBean" class="org.enhydra.jdbc.standard.StandardDataSource" >
        <spring:property name="driverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
        <spring:property name="url" value="jdbc:sqlserver://VIKRAM-PC\MSSQLEXPRESS:1433;databaseName=testsqldb;user=sa;password=mssql;"/>
    </spring:bean>
</spring:beans>

<jms:connector name="jmsConnector" connectionFactory-ref="connectionFactory" specification="1.1" doc:name="JMS" maxRedelivery="3" validateConnections="true"/>

   <jdbc-ee:connector name="Database" dataSource-ref="MSSQLDataSourceBean" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
    <reconnect frequency="5000" blocking="false" count="5"/>        
   </jdbc-ee:connector>



<flow name="hornetqsampleFlow2" doc:name="hornetqsampleFlow2">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="testHornetQ" doc:name="HTTP"/>
    <set-payload value="test HornetQ" doc:name="Set Payload"/>
    <logger message="############# before jms ############ #[message.payload]" level="INFO" doc:name="Logger"/>
    <jms:outbound-endpoint queue="ExampleQueue" connector-ref="jmsConnector" doc:name="JMS" exchange-pattern="request-response"/>
    <logger message="$$$$$$$$$$$$$$ after JMS $$$$$$$$$$$$$$$$$4" level="INFO" doc:name="Logger"/>
</flow>



<flow name="hornetqsampleFlow1" doc:name="hornetqsampleFlow1">
    <jms:inbound-endpoint doc:name="JMS" connector-ref="jmsConnector" queue="ExampleQueue" exchange-pattern="request-response"/>
    <logger message="$$$$$$$ in jms consumption flow $$$$$$$$$$$$" level="INFO" doc:name="Logger"/>
    <jdbc-ee:outbound-endpoint exchange-pattern="request-response"  queryTimeout="-1" doc:name="Database" connector-ref="Database" queryKey="insertque">
        <jdbc-ee:query key="insertque" value="insert into tesdbone(colone,coltwo) values(123,'vikkione')"/>
    </jdbc-ee:outbound-endpoint>
    <!-- <file:outbound-endpoint path="C:\Users\SAN\Desktop" outputPattern="testhq.txt" responseTimeout="10000" doc:name="File"/> -->
</flow> 

Regards Vikram

1

1 Answers

1
votes

To truly decouple the inbound HTTP flow from the outbound JDBC flow with JMS, do not use request-response JMS endpoints but instead use one-way. Moreover, expecting redeliveries from a request-response channel doesn't make much sense.

Then add transactions in hornetqsampleFlow1, either:

  • Using only a JMS local transaction
  • Using an XA transaction

started in jms:inbound-endpoint and joined in jdbc-ee:outbound-endpoint.