Sunday, 19 June 2022

What is a saga?

A saga is a sequence of local transactions, across several services, which maintain their own database. it, therefore, leads to a challenge to keep distributing data states consistently. 

There are two ways of coordinating sagas

  1. Choreography(Event-based):  each local transaction publishes domain events that trigger local transactions in other services.
  2. Orchestration(Command-based):  an orchestrator(object) tells the participants what local transaction to execute. 

Choreography:

All services are linked by a message queue. Service A launches a local transaction for A operation and then sends a message to trigger Service B, and then Service B launches a local transaction B for B operation. Service B may send a message back to service A to report Service A the results.

Service A is an initiator of a business flow, which consists of several independent local transactions.

When a local transaction fails, an initiator is informed, and then the implemented local transactions are rolled back.  




Orchestration:

Orchestrator service is the centre of all services, and it supervises the entire flow of services to carry a business logic dynamically. If one service fails, then the orchestrator may ask for rolling back implemented distributed local transactions. 



Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...