I'm creating a set of Microservices following Event-Driven Architecture using Event-Carried State Transfer to move state from one service to another.
Given the following services;
- Order service
- Shipping service
The Shipping service will subscribe to OrderStarted
, ProductAddedToOrder
OrderAccepted
events and use those events to build up a local datastore.
However, I'm a little confused as to whether an enterprise service bus (Azure Service Bus
) or an event streaming service (Azure Event Hubs
, Kafka
etc) would be more appropriate.
For this type of architecture which would be more ideal and why?
1 Answer 1
For your scenario, an enterprise service bus like Azure Service Bus is better suited as they are designed specifically for it. Because of this, you can benefit from several features like retries, automatic deadlettering, transactional sends with receive, automatic deduplication, etc.
Event streams are most suited for scenarios with huge amounts of events (even millions per second) where the speed of processing is what's most important, that's why some of the previously mentioned features are not available (to make the message delivery as light as possible).
-
1Event streams have another benefit: they are a data source. You can treat the event stream as the single source of truth and consider all databases as derived views of that event stream. See for example the NYT architecture: confluent.io/blog/publishing-apache-kafka-new-york-timesJoeri Sebrechts– Joeri Sebrechts2019年01月08日 08:30:20 +00:00Commented Jan 8, 2019 at 8:30
-
What you mention is not a benefit of Event Streams, but of Event Stores. You can use Kafka as an event store, but you can't use Azure Event Hub for that ("Event Hubs Standard tier currently supports a maximum retention period of seven days. Event hubs are not intended as a permanent data store."). In any case, I wouldn't personally go that route for the question's scenario. I still prefer the benefits from the service bus that I mention in my answer. But thanks for the article, it's very interesting.Francesc Castells– Francesc Castells2019年01月09日 06:32:13 +00:00Commented Jan 9, 2019 at 6:32
-
Ordering is quite important given the pattern we are using. I think Event Hubs ordering is a lot easier to manage over Service Bus's sessions however the other features of Service Bus are appealing.fml– fml2019年02月07日 12:15:16 +00:00Commented Feb 7, 2019 at 12:15
-
I personally don't like to rely on the transport to ensure message ordering. You can deal with out of order messages in your code when it makes sense, as it's not always necessary. In most cases, if an unexpected message arrives, sending it back to the queue and retrying later solves the ordering problem.Francesc Castells– Francesc Castells2019年02月10日 08:31:07 +00:00Commented Feb 10, 2019 at 8:31