Multiple endpoints and conditionals?

kreveksa's picture
I need to work in some conditional logic to one of my proxys Example scenario (see diagram for guide in following along) ESB receives HTTP SOAP message from client ESB transforms the SOAP payload as part of in sequence ESB sends to endpoint #1 Endpoint #1 responds ESB receives response from endpoint and begins processing an out sequence (5.1) As part of out sequence, validity of response is checked (5.2) If good, original message is used, and target endpoint set to endpoint #2 (5.3) If bad, the response is returned to user (step 9) ESB sends to endpoint #2 Endpoint #2 responds ESB receives response from endpoint #2 and begins processing a different out sequence Payload from the outsequence sent back to the client After doing transformations in step 2, I lose the original message content received in step 1. I don't think I can use cloning because that happens in parallel and in this case there is synchronous dependencies (only send to second endpoint if first endpoint was ok). How can I get a message from one endpoint and direct it to another? -Lucas
ruwan's picture

Hi Lucas, What you need is a

Hi Lucas,

What you need is a blocking call to the first endpoint. Try to understand the callout mediator and use it for the first sending and use a normal send mediator with an endpoint for the second endpoint.

Refer to the callout configuration for more details;
http://wso2.org/project/esb/java/1.7.1/docs/ESB_Configuration_Language.html#callout

and this sample
http://wso2.org/project/esb/java/1.7/docs/ESB_Samples.html#Callout

Thanks,
Ruwan Linton

asankha's picture

Lucas Ruwans suggestion will

Lucas

Ruwans suggestion will work for your requirement. If you do not want to block using the callout, you can set a copy of the original message into the message context as a property using a script mediator, and when necessary pick it up again and replace the current message for step 5.2. You can use a scripting language such as groovy for this

asankha

kreveksa's picture

Thanks Ruwan. A callout

Thanks Ruwan. A callout worked nicely in this case.

Previously I found that I could reuse an outsequence multiple times, but that obviously lost important information needed in the original message context that the callout mitigates.

-Lucas

kreveksa's picture

asankha, You read my mind on

asankha,

You read my mind on using properties and manipulating with script mediator. My chain of events looks something like this..
1. property mediator to retain some values
2. script mediator to manipulate payload
3. callout mediator to do some intermediate actions on modified payload
4. script mediator to manipulate payload, reassigning properties captured.
5. final endpoint

-Lucas

asankha's picture

Lucas If my suggestion

Lucas

If my suggestion works, you will not need to use the callout mediator and block waiting for its response. One of the WSO2 engineers from my team will take a look at a sample to show this in the next few days

asankha

Hot Topic
Hot
Topic

Google Gadgets are a nice way to develop user interfaces for distributed services. The fact that they can be hosted anywhere over a network, not necessarily in the very portal server they eventually run in makes them re-usable and allows users to quickly...

Latest Webinar
In this webinar we'll share the range of concerns we've heard from the industry, and survey some of the new and sometimes subtle types of lock-in associated with cloud technologies.
Wednesday, 8 September, 10.00 AM (PDT)