Tutorial : Apigee Edge - Post Client Flow

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?

  • For Message Logging using Message Logging Policy,
    • Similar to sending data to Analytics, you might be using message logging policy in API proxy to log proxy details to syslog / loggly / splunk.
    • If you are implementing message logging policy other than postlclientflow, it's time to move that into postclientflow and improve performance

How to Add PostClientFlow to my API Proxy ?

  • PostClientFlow is supported only in Proxy Response Flow. You can add any policies related to post client flow only in response pipeline.
  • See example XML code below that goes into proxy xml,
<PostClientFlow>

  <Request/>

  <Response>
     <Step>

       <Name>POLICYNAMEGOESHERE</Name>

     </Step>

  </Response>

</PostClientFlow>

Keep us posted if you have any queries.

Comments
akoo
Participant V

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:

  • Implementing any functionality where you would like to process data after sending back response to the client.

looks to be incorrect. Only message logging is allowed. Please confirm, as there are others who are running into the same confusion.

Not applicable

this is my understanding and our experience as well.

anilsr
Staff

@Alex Koo , @Benjamin Goldman , You are right, My bad, I have updated the text. I hope we get that capability moving forward.

Not applicable

@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?

anilsr
Staff

@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.

adas
Participant V

@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.

anilsr
Staff

Thank you @arghya das

Not applicable

Thanks a lot gentlemen.

Not applicable

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!

anilsr
Staff

@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 !

Not applicable

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

gaurav_bhandari
Participant V

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.

edu4krishanu
Participant V

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

anilsr
Staff

@Krish ,

Can you post same as a new question ?

Not applicable

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.

Version history
Last update:
‎02-10-2016 10:26 PM
Updated by: