How to use Apigee Edge Extension of Google cloud PUB/SUB for sending message when backend is not available?

Hi

@Dino-at-Google @ylesyuk

Could you please help me with this as I want to configure Apigee edge eval account extension Google Cloud Pub/Sub and use it in proxy where it sends messages whenever backend is not available to respond.

Any kind of suggestion would be of great help.

0 2 430
2 REPLIES 2

First, I would advise against using the Google Cloud extension.

Google Cloud Pub/Sub has a REST API; you can connect directly from Apigee proxy into Pub/Sub via a ServiceCallout. This will give you better performance and better reliability than the extension, in my estimation. The only wrinkle is to get the right credentials for that call into Pub/Sub. That would be an OAuth token, which you can get from oauth.googleapis.com . We have some samples for doing this, for getting the token. Here is one. And here is another.

That takes care of how you might invoke Pub/Sub from within an API Proxy. The other part of the solution, based on what I understand, is this:

it sends messages whenever backend is not available to respond.

And the key problem is, how do you determine that the backend is not available to respond? Apigee is designed to be a Layer 7 (HTTP) proxy. A call comes in, Apigee examines it, maybe verifies credentials, maybe makes a routing decision, and then makes an outbound call to the upstream system. When the upstream system responds, Apigee can examine or modify that, and then send that modified form to the original client.

When the backend does not respond, the HTTP proxy in Apigee will receive a timeout. You have the ability to set the timeout threshold. Also, you can configure your API proxy so that when a timeout occurs, it performs some other steps, which might include sending a request to Pub/Sub.

Thanks for replying @Dino-at-Google

As I'm going through community question related to PUB/SUB I got this

https://community.apigee.com/questions/65025/has-anyone-done-a-poc-to-connect-google-pubsub-to.html


But in this, we sending messages from pub/sub to apigee edge which I don't see of any use. Instead, I want to use vice-versa. Could you please provide me the steps so that I can set up the PUB/SUB extension in Apigee edge Proxy to push messages into GCP pub/sub API Topic/Subscription.

Thanks for your suggestion and reply.