Event-Carried State Transfer Pattern Nedir?
Açıklaması şöyle
As the name suggests, the main characteristic for the event-carried state transfer pattern is that the events contain state, which is quite different from notification events that just contain an identifier to retrieve state from the producer.
Örnek
Şöyle yaparız
{"specversion" : "1.0","type" : "com.example.orderPlaced","order" : {"id" : "A001-1234-1234","time" : "2020-12-15T00:00:00Z","products" : [{"id" : "1234321","name" : "eBook Seven Languages in Seven Weeks","price" : 25.00,"quantity" : 1}]}}
Açıklaması şöyle. Burada önemli olan event'in içinde işlenmesi için gerekli alanların da olması. Böylece işleyen kod gidip tekrar çağrı yapıp bu bilgileri toparlamak zorunda kalmıyor
Including state in events eliminates the need for the consumer to make a call back to the producer to retrieve state. Instead, consumers build a private replica of state by storing the state from events they consume.
Yani tüketen taraf şu şekilde veri tabanına erişmek zorunda kalmıyor. Eğer üreten taraf zaten bu bilgiye sahipse, veri tabanına yapılan çağrılar azaltılabilir.
User user = userRepository.findById(event.getUserId());
Fat Event vs Delta Event
Açıklaması şöyle
In many publications an event that contains any state is referred to as a fat event. That would make all events that leverage the event-carried state transfer pattern fat events. Some authors, including myself, make distinctions between delta events and fat events. Delta events contain just the properties that changed, so just enough detail, nothing more.
Ne Zaman Kullanılmamalı
Eğe tüketen taraf verinin en son haline ihtiyaç duyuyorsa yani Consumers require real-time accuracy gibi bir durum varsa Event-Carried State kullanılmaz
Hiç yorum yok:
Yorum Gönder