0

I have a mule flow :- I have the following flow :-

<context:property-placeholder location="classpath:conf/DBConnectionProp.properties"/>
<spring:beans>
<spring:bean id="DB_Source" name="DB_Source" class="org.enhydra.jdbc.standard.StandardDataSource">
<spring:property name="url" value="${url}"/>
<spring:property name="driverName" value="${driverName}"/>
</spring:bean>
<spring:bean id="LookUp" name="LookUp" class="com.vertu.services.schema.maindata.v1.Dao.MainDataDAOImpl">
<spring:property name="dataSource" ref="DB_Source"/>
</spring:bean>

<spring:bean id="objectStore" class="org.mule.util.store.SimpleMemoryObjectStore"/>
</spring:beans>


<jdbc-ee:connector name="Database_Global" dataSource-ref="DB_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
<reconnect frequency="1000" count="3" />
<jdbc-ee:query key="InsertQuery" value="INSERT INTO getData(ID,NAME,AGE,DESIGNATION)VALUES(?,?,?,?)"/>
<jdbc-ee:query key="RetriveQuery" value="Select * from getData where ID=?"/>
<jdbc-ee:query key="CheckRowExistsQuery" value="Select count(*) from getData where ID=?"/>
<jdbc-ee:query key="UpdateQuery" value="UPDATE getData SET NAME=?, AGE=?, DESIGNATION = ? WHERE ID=?"/>
<jdbc-ee:query key="DeleteQuery" value="DELETE FROM getData WHERE ID=?"/>
</jdbc-ee:connector>

<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>

<flow name="db_exceptionsFlow" doc:name="db_exceptionsFlow" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" doc:name="SOAP"/>

<until-successful objectStore-ref="objectStore" maxRetries="5" secondsBetweenRetries="10" doc:name="Until Successful">
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl"/> 
</until-successful>

<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<logger message="Response :- #[message.payload]" level="INFO" doc:name="Logger"/>

<catch-exception-strategy doc:name="Catch Exception Strategy">
<jms:outbound-endpoint queue="errorQueue" connector-ref="Active_MQ" doc:name="JMS"/>
</catch-exception-strategy>
</flow>

<!-- <flow name="db_retryFlow" doc:name="db_retryFlow" >
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:errorQueue" doc:name="JMS" exchange-pattern="request-response"/>

<logger level="INFO" message="message :-#[message.payload]" doc:name="Logger"/>
</flow> --> 
</mule>

But now the issue is:-

It is creating errorQueue but no message message is there in the queue when DB server is not available..

Since it is a web service I have put the implement class (com.test.services.schema.maindata.v1.Impl.MainDataImpl) which is responsible for DB operation under until successful

One more issue is incase of success (when DB endpoint is available) it is not showing any response in SOAPUI

Please help... so that I can put the message in ActiveMQ whenever DB endpoint is not available and can retrieve the message from ActiveMQ whenever DB endpoint is available again and use the message for DB interaction ....

Anirban Sen Chowdhary
  • 8,233
  • 6
  • 39
  • 81
  • possible duplicate of [How to store message in ActiveMQ from Mule when Database endpoint not available](http://stackoverflow.com/questions/23578200/how-to-store-message-in-activemq-from-mule-when-database-endpoint-not-available) – Tim Bish May 11 '14 at 11:17
  • I have deleted the previous one ... now I need a solution here – Anirban Sen Chowdhary May 11 '14 at 11:25

2 Answers2

1

The until-successful router is an asynchronous one, i.e. elements after it will execute right away and exceptions happening inside of it will not be propagated outside of it.

To solve your problem, configure a deadLetterQueue endpoint on it so that failed messages end up sent to errorQueue.

Read more about until-successful in the user guide: http://www.mulesoft.org/documentation/display/current/Until+Successful+Scope

David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Hi David , I have modified the code by introducing deadLetterQueue-ref="errorQueue" in until-successful having a global endpoint reference :- < vm:endpoint exchange-pattern="one-way" name="errorQueue" path="dlq" doc:name="VM"/ > ...It ran successfully But still no message went to errorQueue ... pls help – Anirban Sen Chowdhary May 11 '14 at 16:55
  • Don't you want to send these to a JMS queue instead? Like ``? – David Dossot May 11 '14 at 17:09
  • Hi David ... I have added a global JMS endpoint :- < jms:endpoint name="errorQueue" queue="errorQueue" connector-ref="Active_MQ" doc:name="JMS"/ > ... but still no luck ... Still no message is going in the queue ... – Anirban Sen Chowdhary May 11 '14 at 18:44
  • Any suggestion David ? – Anirban Sen Chowdhary May 12 '14 at 16:49
  • Does `MainDataImpl` throw an exception when the DB operation fails? – David Dossot May 12 '14 at 17:57
  • Yes .. I have noticed that If I have a normal jdbc endpoint under until-successful like :- < until-successful objectStore-ref="objectStore" maxRetries="5" secondsBetweenRetries="10" doc:name="Until Successful" > < jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="getOrders" queryTimeout="-1" connector-ref="Global" doc:name="Database"/ > < /until-successful > and call it by http inbound endpoint then the message goes into queue from catch exception strategy incase of failure ... but incase of a webservice when I call from SOAPUI, the mainImpl class in until-sucessful ... – Anirban Sen Chowdhary May 12 '14 at 18:09
  • Interesting. That's maybe due to exception wrapping occurring around the `MainDataImpl` component. Try configuring a `failureExpression` on `until-successful` that checks for the presence of an exception on the current message. – David Dossot May 12 '14 at 18:12
  • After configuring failure expression the exception message is :- org.mule.api.transformer.TransformerMessagingException: Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was RetrieveRequest (javax.jms.JMSException) (org.mule.api.transformer.TransformerException). Message payload is of type: RetrieveRequest (org.mule.api.transformer.TransformerMessagingException). Message payload is of type: RetrieveRequest at org.mule.transformer.AbstractTransformer.process(AbstractTransformer.java:135) – Anirban Sen Chowdhary May 12 '14 at 19:31
  • UPDATE :- SOLVED ... I had just put object to string transformer before jms outbound in catch exception block and now the message is in the queue ... Thanks David .. now only issue is until-sucessfull block dont allow response for the webservice ..which is required in SOAPUI ...,. Any suggestion David to acheive it ?? – Anirban Sen Chowdhary May 12 '14 at 19:53
  • `until-successful` is asynchronous, you need to build the response to the incoming message outside of it. – David Dossot May 13 '14 at 01:59
0

So, the final solution as per David's suggestion is put object to string transformer before jms outbound in catch exception block and now the message is in the queue and is working for me

Anirban Sen Chowdhary
  • 8,233
  • 6
  • 39
  • 81