![Page 1: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/1.jpg)
Apigee@apigee
Santanu Dey@Santanu_Dey
Essential API Facade Patterns
Episode 4 – Synchronous to Asynchronous Conversion
![Page 2: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/2.jpg)
groups.google.com/group/api-craft
![Page 3: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/3.jpg)
slideshare.net/apigee
![Page 4: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/4.jpg)
youtube.com/apigee
![Page 5: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/5.jpg)
@Santanu_DeySantanu Dey
![Page 6: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/6.jpg)
Episode 1Composition
Episode 2Session Management
Episode 3One Phase to Two Phase Conversion
Episode 4Synchronous to Asynchronous Conversion
Webcast Series: API Facade Patterns
![Page 7: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/7.jpg)
Problem
Solution
Benefits
Considerations
Episode 4 : Synchronous to Asynchronous ConversionConversion
![Page 8: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/8.jpg)
Conversion of asynchronous style APIs to synchronous
To enable API teams and app developers to implement and improve their API designs and apps
Problem
![Page 9: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/9.jpg)
Example of a Synchronous API
Client waitsfor the response
API Provider
1. Request
2. Response
![Page 10: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/10.jpg)
Example of a Synchronous API
POST http://example.com/smsmessaging/outbound/tel%3A%2B12345678/requests
{"outboundSMSMessageRequest":{ "address":["tel:+13500000991”],
"senderAddress":"tel:12345678", "outboundSMSTextMessage":
{"message":"Hello World”},
"senderName":"ACME Inc.”}
}
![Page 11: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/11.jpg)
Example of a Synchronous API
Response:
HTTP/1.1 200
{"deliveryInfo": {
"address":"tel:+1350000991", "deliveryStatus":"DeliveredToNetwork”
}}
}
![Page 12: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/12.jpg)
What are the Constructs of an Asynchronous API?
![Page 13: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/13.jpg)
Example of an Asynchronous API
Client does not wait for the completion of the process
API Provider
1. RequestClient
![Page 14: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/14.jpg)
Example of an Asynchronous API
Client does not wait for the completion of the process
API Provider
1. Request
Server calls back
2. Asynch Response
Client
![Page 15: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/15.jpg)
Example of an Asynchronous API
POST http://example.com/smsmessaging/outbound/tel%3A%2B12345678/requests{"outboundSMSMessageRequest":
{ "address":["tel:+13500000991”],
"senderAddress":"tel:12345678", "outboundSMSTextMessage":
{"message":"Hello World”},
"senderName":"ACME Inc.”}"receiptRequest": {
"notifyURL":"http://…/notifications/", "callbackData":”12345"},
}
![Page 16: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/16.jpg)
Example of an Asynchronous API
Immediate Response:
HTTP/1.1 201
{"deliveryInfo": {
"address":"tel:+1350000991", "deliveryStatus":"MessageWaiting”
}}
"receiptRequest": {
"notifyURL":"http://…/notifications/", "callbackData":”12345"},
}
![Page 17: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/17.jpg)
Example of an Asynchronous API
Asynch Call-back Response (A new request):
POST http://Client-app.example.com/notifications/{"deliveryInfoNotification": {
"callbackData": "12345”,"deliveryInfo":
{ "address":"tel:+1350000991", "deliveryStatus":"DeliveredToNetwork"
}}}
![Page 18: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/18.jpg)
The end-user facing application use-case may require synchronous behavior
![Page 19: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/19.jpg)
Having a call back URL from a client-application is not feasible
![Page 20: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/20.jpg)
Solution
![Page 21: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/21.jpg)
The solution is to introduce an API Façade in the middle which can handle the conversion
Synch to Asynch
Asynch. ProviderAsynch Synch
![Page 22: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/22.jpg)
Warning! UML Ahead
![Page 23: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/23.jpg)
![Page 24: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/24.jpg)
![Page 25: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/25.jpg)
When the Target Does not Provide a Call Back
Client does not wait for the completion of the process API
Provider
1. Request
Client checks for the status later
2. Check Status
![Page 26: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/26.jpg)
![Page 27: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/27.jpg)
![Page 28: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/28.jpg)
Example of the API Façade
Backend Server
API Façade
Existing Capabilities
API Exposure &
Mgmt.
App relies on REST
![Page 29: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/29.jpg)
Benefits
![Page 30: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/30.jpg)
The API Façade provides a secure & reliable call back host
![Page 31: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/31.jpg)
Robust callback processing options in the API Façade
![Page 32: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/32.jpg)
This pattern can be applied to mediate REST APIs to asynchronous messaging transports such as JMS
![Page 33: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/33.jpg)
Other Considerations
![Page 34: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/34.jpg)
What is a good timeout for asynch to synch conversion?
![Page 35: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/35.jpg)
Do not abandon the Asynchronous APIs• High throughput• Lower response-time
![Page 36: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/36.jpg)
If you really need a synch API -
Have a synchronous variation of the same API alongside an asynchronous variation
Provide Choice to Developers when Possible
![Page 37: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/37.jpg)
Questions?
![Page 38: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/38.jpg)
THANK YOUSubscribe to API webcasts at:
youtube.com/apigee
Apigee@apigee
![Page 39: Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episode 4)](https://reader035.vdocument.in/reader035/viewer/2022062405/5564a034d8b42afd4f8b4ff7/html5/thumbnails/39.jpg)
THANK YOUQuestions and ideas to:
groups.google.com/group/api-craft
Apigee@apigee