Announcement Announcement Module
No announcement yet.
Newbie: How to chain transformers Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie: How to chain transformers

    Hi, Im having troubles in order to realize how can SI let me get an Object from a JMS queue and then transform it to XML, then apply some transformation using xslt, then back to a new object with different type.

    I already did the JMS interaction but cant realize which component can let me do this kind of chain transformations. I dont know how to use marshalling-transformer, xslt-transformer and unmarshalling-transformer,My main configuration ffollows:

    <channel id="main"/>
    <channel id="inicializarObra"/>
    <channel id="crearProveedor"/>

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <prop key="java.naming.factory.initial">weblogic.jndi.WL InitialContextFactory</prop>
    <prop key="java.naming.provider.url">t3://localhost:9001</prop>

    <bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName" value="jms/ConnectionFactory"/>

    <bean id="receiveDestination" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName" value="jms/CocosinServiceRequest"/>

    <jms-gateway id="jmsSource" connection-factory="queueConnectionFactory"
    destination="receiveDestination" request-channel="main" />

    <router ref="processResolver" method="getProcessType" input-channel="main"/>

    <service-activator ref="logger" input-channel="inicializarObra"/>

    <beans:bean id="processResolver" class="gob.cocosin.integration.obras.contabilidad. ProcessResolver"/>
    <beans:bean id="logger" class="gob.cocosin.integration.obras.contabilidad. Logger"/>

    <!-- How to use this-->
    <marshalling-transformer id="marshaller" marshaller="castorMarshaller"/>

    <beans:bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarsha ller" />

  • #2
    There are two ways to apply transformations one is to use the transformer as a MessageHandler in conjunction with a HandlerEndpoint. The alternative is to carry out the transformation with a queue send or receive call, MessageTransformingChannelInterceptor is provided to allow this.

    Currently both approaches require that an instance of PayloadTransformer be wrapped in a PayloadTransformingMessageHandler.

    <marshalling-transformer id="marshaller" marshaller="castorMarshaller"/>
    <beans:bean id="transformingHandler" class="org.springframework.integration.transformer.PayloadTransformingMessageHandler">
    		<beans:constructor-arg ref="marshaller" />
    If you choose to apply the transformation on the channel then you have the option of having a series of interceptors for the channel each one representing an individual transformation.

    <channel id="tranformingChannel">
    	<interceptor ref="oxmTransformingInterceptor"/>
    	<interceptor ref="xsltTransformingInterceptor"/>
    Alternatively you can use a handler chain in conjunction with either a HandlerEndpoint or MessageTransformingChannelInterceptor.

    <handler-chain id="transformationChain">
    	<handler ref="transformingHandlerOne"  />
    	<handler ref="transformingHandlerTwo" />