I'm trying to learn Camel on Fuse- within this example an ActiveMQ message is converted in a Java object named CustInfo using the Dozer component:
<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&targetModel=org.blogdemo.homeloan.model.CustInfo&unmarshalId=homeloancust&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>
My question is, in case I don't need transformations in the Java object, can I convert the message into the Java class directly (without Dozer). Tried with:
<bean id="CustInfo" class="homeloancust.CustInfo"/>
. . .
<to ref="CustInfo" id="to3"/>
Without success! Any help ?
Assuming that the incoming message has a contract (which it should if it follows a good contract-first approach), then you can simply unmarshall the payload into a Java object using JAXB. If it doesn't have a contract, you can still annotate your Java class with JAXB annotations and unmarshall to it:
<unmarshal>
<jaxb prettyPrint="true" contextPath="org.apache.camel.example"/>
</unmarshal>