In event-driven architecture, is it ok to have all services send their event to a component that forwards it to the proper service?

event-driven architecture best practices
event-driven architecture pros and cons
event-driven architecture java
event-driven architecture kafka
event-driven architecture pdf
event-driven architecture python
event-driven architecture c#
event-driven architecture martin fowler

Let's say I want to set up and event-driven architecture with services A-D where the events propagate as follows

          /   \
         B     C

In other words,

(1) A publishes an event

(2) Subscribers B and C receive A's event

(3) C publishes an event

(4) Subscriber D receive's C's event

One way is to have services B and C directly listen to a queue into which A posts messages. But the issue I see with this is maintenance. Once the system becomes complicated with 1000s of subscriptions, it becomes difficult to have any visibility into how the updates are propagating.

A solution I propose to this problem is to have another service X that knows the tree in the in the first image and is responsible for directing the propagation of events according to the tree. Every service publishes its event to X and it publishes the event to the listening services. So it's kinda of a middleman like

    / \
   B   C

This also makes it easier to track the event propagation.

Are there any downsides to this (other than extra cost associating with twice as much message transferring)?

You’re thinking of events like they are implemented in a Winforms UI where the publisher sends the event directly to the subscriber. That’s not how events work in an EDA architecture. The word "event" has taken on a whole new meaning.

Before we start, you’re jumbling together the ideas of a message and an event when they really need to be kept separate. A message is a request for some action to happen, while an event is notification that something has already happened. The important distinction for this discussion is that a message publisher assumes 1 or more other processes will receive and process the message. If the message is not processed by something, downstream errors will occur. An event has no such assumption and can go unread without adversely affecting anything. Another difference is that once messages are processed they are typically thrown away, whereas events are kept for an extended period (days, or weeks).

With that in mind, the ‘X’ service you talk about already exists (please don’t build one) and is integral to the process – it’s called the bus. There are 2 types of bus; a message bus (think RabbitMQ, MSMQ, ZeroMQ, etc) or event bus (Kafka, Kinesis, or Azure Event Hub). In either case, a publisher puts a message on to the bus and subscribers get it from the bus. You may implement the bus servers as multiple physical buses, but when imagining it think of them all being the same logical bus.

The key point that’s tripping you up, and it’s a subtle difference, is thinking that the message bus has business logic indicating where messages go. The business logic of who gets what message is determined by the subscribers – the message bus is just a holding place for the messages to wait for pickup.

In your example, A publishes an event to the bus with a message type of "MT1". B and C both tell the bus that they are interested in events of type "MT1". When the bus receives the request from B and C to be notified of "MT1" messages, the bus creates a queue for B and a queue for C. When A publishes the message, the bus puts a copy in the "B-MT1" queue and a copy in the "C-MT1" queue. Note that the bus doesn’t know why B and C want to receive those messages, only that they’ve subscribed.

These messages sit there until processed by their respective subscribers (the processes can poll or the bus can push the messages, but the key idea is that the messages are held until processed). Once processed, the messages are thrown away.

For C to communicate with D, D will subscribe to messages of type "MT2" and C will publish them to the bus.

Constantin’s answer above has a point that this is a single point of failure, but it can be managed with standard network architecture like failover servers, local message persistence, message acknowledgements, etc.

One of your concerns is that with 1000’s of subscriptions it becomes difficult to follow the path, and you’re right. This is an inherent downside of EDA and there’s nothing you can do about it. Eventual consistency is also something the business is going to complain about, but it’s part of the beast and is actually a good thing from a technical perspective because it enables more scalability. The biggest problem I’ve found using the term Eventual Consistency is that the business thinks it means hours or days, not seconds.

BTW, This whole discussion assumes the message publishers and subscribers are different apps. All the same ideas can be applied within the same address space, just with a different bus. If you’re a .net shop look at Mediatr. For other tech stacks, there are similar solutions that I’m sure google knows about.

2. Event-Driven Architecture, What is event driven architecture EDA and why does it matter? An event driven architecture can use a pub/sub model or an event stream model. Pub/sub: The messaging infrastructure keeps track of subscriptions. When an event is published, it sends the event to each subscriber. After an event is received, it cannot be replayed, and new subscribers do not see the event. Event streaming: Events are written to

If your main concern is visibility into the propagation of events (which is a very valid concern for debugging and long-term application maintenance of a distributed system), you can use a correlation identifier to trace the generation of messages from the initial event through the entire chain. You don't need to build another layer of orchestration -- let your messaging platform handle that for you.

Most messaging platforms/libraries have the concept built in: e.g., NServiceBus defines a ConversationId field in the message headers, and AMQP defines a correlation-id field in the basic messaging model.

Your system should have some kind of logging that allows you to audit messages -- the correlation ID will allow you to group all messages that result from a single command/request to make debugging distributed logic much simpler.

If you set a GUID in the client requests, you can even correlate actions in the UI to the backend API, right through all the events recursively generated.

Event-driven architecture, When a Microservice publishes an event when something notable happens and other Microservices subscribes to those events is called? Service-Oriented Architecture (SOA) and Event-Driven Architecture (EDA) are two different paradigms that address complex integration challenges. How can organizations choose the better approach to meet their needs? Actually they don't have to choose: an Enterprise Service Bus (ESB) allows for the implementation of both the SOA and the EDA concepts.

It is OK but the microservices shouldn't care how they get the messages in the first place. From their point of view the input messages just arrive. You will then be tempted to design your system to depend on some global order of events, which is hard in a distributed scalable system. Resist that temptation and design your system to relay only on local ordering of events (i.e. the ordering in an Event stream emitted by an Aggregate in Event sourcing + DDD).

One downside that I see is that the availability and the scalability may be hurt. You will then have a single point of failure for the entire system. If this fails everything fails. When it needs to be scaled up then you will have again problems as you will have distributed messaging system.

What is event-driven architecture?, Event-driven architecture (EDA) is a software architecture paradigm promoting the production, Emitters have the responsibility to detect, gather, and transfer events. An transform and forward the event to another component or it might provide a Building systems around an event-driven architecture simplifies horizontal  In one of my previous posts, I discussed the evolution of application architecture from monolithic to service-oriented to microservices and eventually, to event-driven. I concluded that post with a brief introduction to event-driven architecture (EDA) and promised to dive deeper into the topic in a future post. Well, here we are.

Implementing event-based communication between microservices , If you're an enterprise architect, you've probably heard of and worked In event-​driven architecture, when a service performs some piece of work that other services might be interested in, that service produces an event—a record stream that publishes the event and allows access to all interested parties. Event-driven SOA is a form of service-oriented architecture (SOA), combining the intelligence and proactiveness of event-driven architecture with the organizational capabilities found in service offerings. Before event-driven SOA, the typical SOA platform orchestrated services centrally, through pre-defined business processes, assuming that

Best Practices for Event-Driven Microservice Architecture, These components have been built using different technologies, and run in Service-Oriented Architecture (SOA) is an architectural paradigm for creating and that they are based on Internet and Web standards, in particular, Web services. to numerous recipients about the event so they can take appropriate action [5]. Event-driven architecture is an architectural style where components in the system emit events and react to events. Instead of component A directly calling component B when some event occurs, component A just emits an event.

Transactions on Computational Collective Intelligence I, ing environment, meaning that clients and services are using communication protocols built on top of IP, and that all INDISS is composed of a set of event-​based components, and their This component also captures/collects network messages sent by clients and services onto these multicast groups, and forwards them  We hear a lot about event-driven architecture these days, especially in the context of microservices. For instance, Gartner has identified this as one of the top 10 technology trends for 2018.