In short, I am interested in building loosely coupled Microservices connected via SNS (for the most part) in order to process API requests in real-time.
Premise
- Need all of this to occur within a single POST request response body
- Cannot ask the client to pull for success upload and/or successful routing.
AWS API Gateway Endpoints
- POST /api/documents/uploadAndRouteDownWorkflow, executes documents.upload and receives a combined response from documents.upload and workflows.routeDocument functions indicating full success (upload and route worked), partial success (upload but not route), or complete failure (upload failed)
Lambda Functions (executed in order):
- documents.upload
- Invoked from API Gateway endpoint
- Uploads documents to a DMS (Document Management System)
- Creates a SNS message to a workflow microservice in order to route document
- workflows.routeDocument
- Invoked from subscribed SNS topic
- Routes document/documents in SNS message
- Returns a success/failure to the original api request
Caveats why documents.upload does not invoke worksflows.routeDocument internally
- Microservices not loosely coupled anymore
- Double compute time for both lambda functions if forcing to be synchronous (is it possible )
Is this pattern possible?
Thanks!