-
1. Re: JAXB marshaling multiple elements from Camel CXF to Active MQ and unmarshal
davsclaus Jan 29, 2013 2:43 AM (in response to milanmilas)If the ChatMessage POJO is the XML you want, then you can let Camel automatic convert it to/from XML using JAXB (camel-jaxb) with the implicit type converters.
Though as you use CXF there is one caveat is that you need to convert POJO first. And then to XML afterwards, which you can convert to as a String.
<from uri="cxf:bean:serviceEndpoint?dataFormat=POJO"/> <convertBodyTo type="com.pocesb.ChatMessage"></convertBodyTo> <convertBodyTo type="String"></convertBodyTo> <inOnly uri="activemq:topic:Producer"></inOnly>
But when sending to a JMS queue you can tell Camel which JMS message type to use. And if you say Text, then Camel will automatic convert to a String, so the route can be
<from uri="cxf:bean:serviceEndpoint?dataFormat=POJO"/> <convertBodyTo type="com.pocesb.ChatMessage"></convertBodyTo> <inOnly uri="activemq:topic:Producer?jmsMessageType=Text"></inOnly>
And on the consumer side you can convert to the POJO. Assuming the POJO class has JAXB annotations.
<from uri="activemqconsumercxf:queue:Consumer"/> <convertBodyTo type="com.pocesb.ChatMessage"></convertBodyTo>
And the jmsMessageType option only applies to the producer, so we can remove that.
-
2. Re: JAXB marshaling multiple elements from Camel CXF to Active MQ and unmarshal
milanmilas Jan 30, 2013 12:05 PM (in response to davsclaus)That's ok if my method is accepting only ChatMessage
-Send(ChatMessage message)
but what if my method has two parameters
-Send(ChatMessage messsage, Person person)
I suppose that ConvertBody to won't work or it can work only for one parameter in the
List of parameters.
But the question is how to do everything from your sample code for two parameters?