Hello Everyone,
In this video, We will see why to use post client flow and how it will impact the performance of an API proxy if you would like to do some processing after sending the response back to the client in API flow.
Why PostClientFlow?
It's implemented to improve the performance of Apigee API proxy. Before this flow, we use to send API Proxy data to analytics in Proxy Post flow. Ideally, this can be done even after sending the data to the client. Now, If you see data is send to AX in PostClientFlow.
How can I use PostClientFlow in my API Proxy?
How to Add PostClientFlow to my API Proxy ?
<PostClientFlow> <Request/> <Response> <Step> <Name>POLICYNAMEGOESHERE</Name> </Step> </Response> </PostClientFlow>
Keep us posted if you have any queries.
Thank you for this informative post, @Anil Sagar-- it's very helpful. I had an important comment: seems I can only use message logging policy in postclientflow. I.e., your statement on allowing the following:
looks to be incorrect. Only message logging is allowed. Please confirm, as there are others who are running into the same confusion.
this is my understanding and our experience as well.
@Alex Koo , @Benjamin Goldman , You are right, My bad, I have updated the text. I hope we get that capability moving forward.
@Anil Sagar - "Usage notes" section of "Message logging policy" says - "Edge logs message asynchronously, meaning that no latency that might be caused by blocking callouts is introduced to your API."
Is this true only when message logging policy is used inside Post Client Flow (as this video indicates), or it is asynchronous irrespective of location this policy is placed at?
@sanjeev kumar , Yes, I believe irrespective of location, Message logging policy logs message asynchronously. Time it takes to execute / invoke policy can be saved if same implemented in post client flow. It's always recommended to implement same in POST Client Flow. @arghya das Is that how it works ? Correct me if i am wrong.
@Anil Sagar That's right. The message logging does work asynchronously. But moving it to the post client flow makes it a fraction better since the client response is already sent so any delay in invoking the policy is outside of the actual request/response flow.
Thank you @arghya das
Thanks a lot gentlemen.
Hi @Anil Sagar,
Thanks a lot for sharing this information!
We have logging implemented in PostSlientFlow. Unfortunately, response body doesn't seem to be available in this flow. Nothing gets printed to the log and trace shows that variable response.content is empty. Any idea how we could log response body? Thank you in advance!
@Andrei Filippov , Are you oncloud ? How can i reproduce your issue ? Is there a sample proxy bundle ?
I will give it a try & keep you posted. Stay tuned !
Hi @Anil Sagar,
Thanks a lot for getting back to me! No, I'm using on prem version 4.16.01.04.
I posted a copy of my logging policy here
Hi @arghya das,
One more advantage of having it in the post client flow is that this flow will always execute even it there is any failure.
If we keep Message logging in preplow/postflow/conditional flow, then there are changes that the policy is not invoked.
HI @Anil Sagar,
I have a message logging policy in the post client flow. I want to write a response content which is sent to the client in the log. Do you know if apigee has any reference variable I can use in post client which gives the information? I used response.conetnt and message.content, both didn't work.
Thanks.
Krish
@Krish ,
Can you post same as a new question ?
I added
<PostClientFlow> <Request/> <Response> <Step> <Name>Python-TokenDelay</Name> </Step> </Response> </PostClientFlow>
And get an error while saving
"Bundle is invalid. Errors:[Entity : PostClientFlow, Script policy is not supported in the response flow;]."
I wish to send a message to a queue in the PostClientFlow (likely by Python or Javascript)...
I prefer not to slow the client response by doing it earlier.