2016-04-14 73 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

这是我的荣幸。 –