Best practice when working pre-flow,post-flow,conditional flow

Hi All,

I have a scenario, where I am exposing an Open API with say one resource (that creates one conditional flow). Once received request, the flow/proxy has to:

- Get Salesforce token.

- Create a job in SF - have to use above token as part of the request.

- Retrieve results from SF - have to use above token as part of the request.

All these have 3 different HTTP backend end-points. What I need here is, best practice to structure the proxy (reverse proxy), my understanding is below:

- Get Salesforce token in pre-flow (of proxy end-point) and store it in a cache.

- The conditional flow that would be created as part of OpenAPI : Can we handle the remaining logic here (like above create a job, and retrieve). I know whatever case, finally HTTP target end-point will be invoked.

How to avoid this, or is there any specific way to handle this?

Many thanks!!

0 2 270
2 REPLIES 2

sidd-harth
Participant V

Yes, your understanding is correct. I just want to add one point on caching,

In Preflow add the logic to get the token and cache it with the help of Populate and LookUp Cache so that you only make a call to the token endpoint once and will cache the token till it expires.

In Conditional flow Create a job in SF using Service Callout policy and for Retrieve results from SF just add a Assign Message policy to set the token header appropiately before hitting the Targetndpoint.

Thanks.

- Ok, so if I understand correct on Conditional flow (request) - the last one will be assign message and the below part of xml needs to be update (within conditional flow)? and hope the below would act as a callout!!

<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>

In the above case, what would be HTTPTargetConnection in the Target End-point? does it not execute at all?