2016-04-14 72 views
1

我想這個例子中的ActiveMQ消息被轉換在名爲CustInfo使用推土機組件的Java對象中學習駱駝上保險絲 - :從ActiveMQ的爲Java Bean

<camelContext id="context-43faded0-825e-454b-8037-c72122aa0418" xmlns="http://camel.apache.org/schema/blueprint"> 
    <propertyPlaceholder location="classpath:sql.properties" id="properties"/> 
    <endpoint uri="dozer:toCustInfo?sourceModel=homeloancust.CustInfo&amp;targetModel=org.blogdemo.homeloan.model.CustInfo&amp;unmarshalId=homeloancust&amp;mappingFile=toCustInfo.xml" id="toCustInfo"/> 
    <dataFormats> 
    <jaxb contextPath="homeloancust" id="homeloancust"/> 
    </dataFormats> 
    <route id="CustomerEvaluation"> 
     <from uri="activemq:queue:customer"/> 
     <to ref="CustInfo" id="to3"/> 
     . . . . 
    </route> 
</camelContext> 

我的問題是,萬一我不需要在Java對象中進行轉換,我可以直接將消息轉換爲Java類(沒有推土機)。 試用版本:

<bean id="CustInfo" class="homeloancust.CustInfo"/> 
. . . 
<to ref="CustInfo" id="to3"/> 

沒有成功!任何幫助?

回答

1

假設傳入消息有一個契約(如果遵循一個好的契約優先方法,它應該是這樣的),那麼你可以簡單地使用JAXB將有效載荷解組成Java對象。如果沒有合同,你仍然可以用註釋JAXB標註Java類解組到它:

<unmarshal> 
    <jaxb prettyPrint="true" contextPath="org.apache.camel.example"/> 
</unmarshal> 

http://camel.apache.org/jaxb.html

+0

感謝您的幫助! – Carla

+0

這是我的榮幸。 –