Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request based vs Event based architecture

Q1

I know the fundamental different between event based vs request based/driven architecture. Question is if the Request-based always done in synchronously while the Event-based is always done in asynchronously ?

Q2

Also, in API world (request-response), you normally return 400 http code for if the request message is invalid. And fortunately, in API world we can perform contract testing making the integration to be more robust.

What would be the best way to handle this similar issue in the messaging queue other than putting the message in the error queue ? is it the responsibility of the pubsliher service or consumer service to get notified first of the problem ?

like image 445
bet Avatar asked Feb 25 '19 21:02

bet


People also ask

Which of these is an advantage of event based architecture?

Event-driven architecture enables increased resilience because it reduces dependencies between applications. If a particular service fails, it can autonomously restart, recover events, and replay them if needed.

How is event-driven architecture different?

An event-driven architecture uses events to trigger and communicate between decoupled services and is common in modern applications built with microservices. An event is a change in state, or an update, like an item being placed in a shopping cart on an e-commerce website.

What is event-driven architecture example?

An Event-Driven Architecture for data and applications is a modern design approach centered around data that describes “events” (i.e., something that just happened). Examples of events include the taking of a measurement, the pressing of a button, or the swiping of a credit card.


1 Answers

Q1

That's the fundamental difference. The event publisher doesn't care who consumes it. In req/response services are tied up.

Q2

In event driven system it's responsibility of publisher to include everything that other services can use. In case the event doesn't contain everything that it needs then you can't publish event at the first place so you need to make sure that's the case. This is whole point of event driven since consumer expects to pick the message with all the data it needs.

If you still are able to publish the event that wasn't well formatted then you would reject the event and definitely log it . If that rejected event was part of transaction and linked to publish of another event then you would raise the failed processing event (Saga Pattern).

The best practice is to raise event with all the necessary payload. If events are not well formatted then It's a bad design and will eventually get complicated to handle at large scale.

like image 188
Imran Arshad Avatar answered Oct 12 '22 10:10

Imran Arshad