I'm reading messages from a JMS queue using a jms:inbound-gateway.
These messages have a xml payload, so I use a si-xml:unmarshalling-transformer to transform them to domain objects.
However what the UnMarshalling transformer passes to the output channel are JaxbElements. Is there a way to pass the actual value of the JaxbElment, because the service activator needs the domain object and not the JaxbElement. The same goes for the reverse transformation. The si-xml:marshalling-transformer needs a JaxbElement, where I would like to pass a domain object. Is there a way to do this? Because it seems rather stupid to write a transfomer that just does quot;element.getValue()quot; ?
I've used XML over JMS and JAXB without any problems, it always puts domain objects on the channel. Can you post your config?
This is my config:Code:
lt;bean id=quot;jmsContainerquot;
class=quot;org..jms.listener.DefaultMessageListenerContainerquot;gt;
lt;property name=quot;connectionFactoryquot; ref=quot;connectionFactoryquot; /gt;
lt;property name=quot;destinationquot; ref=quot;replyQueuequot; /gt;
lt;property name=quot;messageListenerquot; ref=quot;messageListenerquot; /gt;
lt;/beangt;
lt;bean id=quot;messageListenerquot; class=quot;Testquot;gt;lt;/beangt;
lt;jms:inbound-gateway id=quot;jmsinquot;
default-reply-destination=quot;replyQueuequot; request-destination=quot;requestQueuequot;
concurrent-consumers=quot;10quot; request-channel=quot;xmlToObjectquot; /gt;
lt;bean id=quot;connectionFactoryquot;
class=quot;org..jms.connection.CachingConnectionFactoryquot;gt;
lt;property name=quot;targetConnectionFactoryquot;gt;
....
lt;/propertygt;
lt;/beangt;
lt;integration:channel id=quot;xmlToObjectquot; /gt;
lt;integration:channel id=quot;objectToXmlquot; /gt;
lt;integration:channel id=quot;incomingMappingquot; /gt;
lt;integration:channel id=quot;outgoingMappingquot; /gt;
lt;integration:channel id=quot;engineChannelquot; /gt;
lt;si-xml:unmarshalling-transformer id=quot;defaultUnmarshallerquot;
input-channel=quot;xmlToObjectquot; output-channel=quot;incomingMappingquot;
unmarshaller=quot;unmarshallerquot; /gt;
lt;si-xml:marshalling-transformer
input-channel=quot;objectToXmlquot; marshaller=quot;unmarshallerquot;
result-transformer=quot;resultTransformerquot; /gt;
lt;bean id=quot;resultTransformerquot;
class=quot;org..integration.xml.transformer.ResultToStringTransformerquot; /gt;
lt;integration:transformer id=quot;incomingMapperquot;
ref=quot;mapperquot; input-channel=quot;incomingMappingquot; method=quot;mapIncomingMessagequot;
output-channel=quot;engineChannelquot; /gt;
lt;integration:transformer id=quot;optimizationEnginequot;
ref=quot;enginequot; input-channel=quot;engineChannelquot; method=quot;optimizequot;
output-channel=quot;outgoingMappingquot; /gt;
lt;integration:transformer id=quot;outgoingMapperquot;
ref=quot;mapperquot; input-channel=quot;outgoingMappingquot; method=quot;mapOutgoingMessagequot;
output-channel=quot;objectToXmlquot; /gt;lt;integration:poller id=quot;pollerquot; default=quot;truequot;gt;
lt;integration:interval-trigger interval=quot;1000quot; /gt;
lt;/integration:pollergt;lt;bean id=quot;marshallingTransformerquot;
class=quot;org..integration.xml.transformer.XmlPayloadMarshallingTransformerquot;gt;
lt;constructor-arggt;
lt;ref bean=quot;unmarshallerquot; /gt;
lt;/constructor-arggt;
lt;property name=quot;resultFactoryquot;gt;
lt;bean
class=quot;org..integration.xml.result.StringResultFactoryquot;gt;lt;/beangt;
lt;/propertygt;
lt;/beangt;lt;bean id=quot;unmarshallerquot; class=quot;org..oxm.jaxb.Jaxb2Marshallerquot;gt;
lt;property name=quot;contextPathquot; value=quot;core.messagequot;gt;lt;/propertygt;
lt;property name=quot;schemaquot;
value=quot;classpath:core/message/xml/Message.xsdquot;gt;lt;/propertygt;
lt;/beangt;
lt;bean id=quot;mapperquot;
class=quot;online.OptimizationEngineMessageToGenericMessageMapperquot;gt;
lt;/beangt;
When mapIncomingMessage is public GenericMessage mapIncomingMessage(OptimizationEngineMessage message) throws Exception
it doesn't work, changing it to public GenericMessage mapIncomingMessage(JAXBElementlt;OptimizationEngineM essagegt; input) throws Exception it works.
Why doesn't the first thing work? |