-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payload Enricher with request-payload-expression="payload.username" #346
Comments
Additionally, while trying out the use case 3, I notice that the XML does not do any explicit transformation between the returned User object and the User map. However, with the Java DSL, I am getting the below error. Would you be able to suggest on this payload transformation?
Referred XML:
|
Would you mind to the share with us a the whole configuration for this task and explain what you try to achieve? It feels like you are missing the reasoning behind an Enricher pattern: https://www.enterpriseintegrationpatterns.com/patterns/messaging/DataEnricher.html. In two words it does this: takes some additional data and populates it as an addition to the request data. To be more specific here is what is going on in that
The Java DSL for this XML might look like this:
There is no automatic conversion to a |
Example#2: Pass only the username to the request channel by using the request-payload-expression attribute Implementation: Enrich the payload with the username -> send to a handle method (Service Activator)
|
Your |
Yeah... You definitely need to learn what is that Enricher pattern. |
Based on your comments, I used the requestSubFlow() method to handle the sample payload
Based on this I observe the below changes in payload through the flow but am unable to get any message in the main flow. Is there still some issue in the implementation?
|
You still use
Not sure if you will still need those |
After analyzing, the confusion started due to 2 issues:
Issue 1 is resolved by using the requestPayloadExpression since it can "send only a subset of the original payload by using the request-payload-expression attribute." - https://docs.spring.io/spring-integration/reference/html/content-enrichment.html#payload-enricher I am unable to resolve issue 2. I get the response: User [username=foo, password=null, email=null] I tried it together with replyChannel where the handle method should send the output to a channel on which the gateway will listen for a response Gateway
Service
If I provide the handle method directly, I get this as response: User [username=User [username=foo, password=null, email=null], password=secret, email=User [username=foo, password=null, email=null]@springintegration.org]
How do we ensure the output of the handle method goes back to the main flow? |
Based on your earlier comments, I tried this and it worked. Would this be the right approach to this? Output: User [username=foo, password=secret, email=[email protected]]
the propertyExpression method is used to set values to the properties. If the property is not defined in the User object, it throws the error: |
You need to step back and see if just a What else would you expect if there is no getter for the property you request from SpEL? |
While trying out the enricher example by using Java DSL, I am unable to replace the payload that contains User object with only username field using the method:
.enrich(p -> p.requestPayloadExpression("payload.username"))
--> https://docs.spring.io/spring-integration/reference/html/content-enrichment.html#payload-enricher
However, the payload functionality works when I use the transform method that takes in an expression parameter
.transform("payload.username")
Is the transform method the only way to update the payload?
The text was updated successfully, but these errors were encountered: