Lecture 5: Microservices Flashcards
Service API Patterns
- RPC
- Message
- Resource
RPC
- send messages that encapsulate the semantic procedure or method execution in order to execute a functional method
- method name and parameter method needed
Message API
- sending commands or events to remote systems over HTTP while avoiding the direct coupling to remote procedures
Resource API
- manipulate data by a remote system while avoiding direct coupling to remote procedures and minimise the need for domain-specific APIs
Service Interaction Patterns
- Request/Response
- Request/Acknowledgement
- Request/Acknowledgement/Poll
- Request/Acknowledgement/Callback
- Linked Services
Request/Response
- Process requests when they are received and return results over the same client connection without any delay! (flight search)
Request/Acknowledge
First validate the request and schedule the processing of the request and then return the acknowledgement indicating that or containing unique request identifier, the processing of the request will occur later.
Request/Acknowledge/Poll
This pattern allows client to poll whenever the client wants
Request/Acknowledge/Callback (relay)
The callback service can also act as a relay which means it simply receive the callback message and then forward that message to one or more service
Linked Services
Here the client only needs to know the addresses of one or more services in RESTFUL services
Service Collaboration/Composition Patterns
- Choreography
- Orchestration
Choreography
- Direct interaction (via Message Broker) for services
- No central controller!
Orchestration
- Composite service acts as controller
Client-Service Communication/Access Patterns
API Gateway
- Can provide cross-cutting services such as authentication, caching, logging. routing. circuit breaker, rate controller and so on
- Per bounded context or for each client application type (backend for frontend pattern)
SAGA Pattern
- Sequence of local transactions
- Transaction Rollback: if local transaction fails, the SAGA executes a series of compensating transactions that undo the changes that were made by the preceding local transactions (booking -> customer decides to cancel)
- SAGA Choreography or SAGA Orchestration