Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Java callout via Flow Hooks

Hi,

Been spending a few days trying to make this work, getting a little frustrated here 🙂

I am developing a "Java Callout" that I'd like to invoke from the Flow Hooks mechanism so this Java Callout runs for every API Proxy request/response. In this Callout, I have to:

  • Access request/response headers
  • Communicate with external server via REST.
  • Impact performance as little as possible.

I have a few questions:

I need to grab some headers that only exist in the Client request, before it is modified by any API Proxy,
But I am also interested in headers and body that will be sent to the client after the target backend server replies etc... In other words, I believe I have to use both Pre-Proxy and Post-Proxy Flowhooks.

I want to gather some data from the request, store it somewhere until the response arrives, gather some data from response, apply some logic, and communicate with external server.  This has to happen for each transaction on any API Proxy affected by the flow hook.

My questions:

  1. Is storing data on messageContext.setVariable("somekey", "somedata") the right way? Is messageContext unique per session?
  2. Should "executionContext.isRequestFlow()" be working for me? It always returns true.
  3. Running a debug session, I see variable and properties such as:
    proxy.flow.name / current.flow.name etc...
    Trying to access these from messageContext.getVariable("proxy.flow.name") or messageContext.getVariable("{proxy.flow.name}") (also current.flow.name) and other combinations never return a value.
    What am I doing wrong?

I have read the docs, I have seen the solution by @dino where a wrapper function first check the properties provided by the policy on instantiation, and it returns a curly braced string, fetch it using getVariable.  It doesn't work for me.

Thanks!
ED.

0 2 236
2 REPLIES 2