spring-boot-migrator icon indicating copy to clipboard operation
spring-boot-migrator copied to clipboard

Mule: Add ability to access headers during transformation

Open sanagaraj-pivotal opened this issue 3 years ago • 0 comments

What needs to be done

Currently, DWL transformations are translated as below

Sample input
        <dw:transform-message doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
(flowVars.someVar splitBy ",") map ("'" ++ $ ++ "'") joinBy ","]]></dw:set-payload>
        </dw:transform-message>
Generates following translation/output:
 @Bean
    IntegrationFlow transform() {

        return IntegrationFlows.from(...)
                ... 
               .transform(TransformClass::transform)
                ...
                .get();
    }
class TransformClass {
    /** contents of DWL transformation will be pasted as comments*/
    public static TransformClass transform(Object payload) {
    }
}

If you look at the above TransformClass there is only access to payload not headers

We need provision to access both headers and payload whilst transformation.

Why it needs to be done

In mule transformations, there will be instances where we need to access headers and payload whilst performing translations. This is evident from client applications that we have encountered where this pattern is used prolifically.

Additional Information

Possible solution can be found here.

sanagaraj-pivotal avatar May 26 '22 15:05 sanagaraj-pivotal