如何从Mule中的webservice类在ActiveMQ队列中发送消息

时间:2014-05-11 10:52:44

标签: web-services cxf activemq mule mule-studio

我有一个骡子流: - 我有以下流程: -

<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>

但现在的问题是: -

正在创建errorQueue但是没有消息消息 DB服务器不可用时排队..

由于它是一个Web服务,我已经把实现类(com.test.services.schema.maindata.v1.Impl.MainDataImpl)负责DB操作直到成功

另一个问题是成功(当DB端点可用时)它没有在SOAPUI中显示任何响应

请帮助......这样我就可以在DB端点不可用时将消息放入ActiveMQ中,并且只要DB端点再次可用,就可以从ActiveMQ检索消息,并使用该消息进行数据库交互....

2 个答案:

答案 0 :(得分:1)

until-successful路由器是一个异步路由器,即它之后的元素将立即执行,其中发生的异常不会传播到它之外。

要解决您的问题,请在其上配置deadLetterQueue端点,以便将失败的消息发送至errorQueue

在用户指南中详细了解until-successfulhttp://www.mulesoft.org/documentation/display/current/Until+Successful+Scope

答案 1 :(得分:0)

所以,按照David的建议,最终的解决方案是在{catch}异常块中的jms outbound之前放置object to string transformer,现在消息在队列中并且正在为我工​​作