After some time seeing companies adopting (sometimes without real justification) microservice-based architectures, we see a growing interest in event-driven architectures.

In this and other posts, we will introduce some key concepts and recurring patterns for using events in software development. Let’s start with systems that implement event notifications.

Understanding the basics

Imagine a system where every time a component (module, microservice, etc.) completes an operation, a related activity must start on another component.

For example, consider an e-commerce system where, once a sale has been confirmed, it is necessary to trigger the process of picking and to ship a product.

A simple approach would be to have the first component actively trigger the second component (by calling a method, making a request to some specific endpoint, sending a “command” message, etc.).

In our example, we might consider that the sales system would “call” the shipping system with a request to an endpoint, or, in a monolithic scenario, by executing a method.

A more complex sophisticated solution, however, would be to have the first component “firing” a message notifying the occurrence of a business event through an event bus. Then all other components registered in the event bus to receive this type of message would be triggered.

Thus, in our example, we could have the sales system “sending” an event message with sales-related data that has just been made. In the meantime, the shipping system would be “listening” to this event ready to do its work.

This approach has the positive side effect of allowing other components to “listen” to the same event by allowing additional processing to run without having to change the parts that are already working in the system.

Why develop systems with event notification?

Distributed systems (including those based on microservices) are becoming increasingly common. In these systems, one of the most important architectural attributes is loose coupling.

From Wikipedia:

In software engineeringcoupling is the degree of interdependence between software modules; a measure of how closely connected two routines or modules are; the strength of the relationships between modules.

Coupling is usually contrasted with cohesionLow coupling often correlates with high cohesion, and vice versa. Low coupling is often a sign of a well-structured computer system and a good design, and when combined with high cohesion, supports the general goals of high readability and maintainability.

In practical terms, we want to develop, distribute and maintain systems by changing their parts without affecting the others. The communication strategy between components, employing event notification, helps to develop systems with louse coupling.

Back in 2002, I worked on developing a complex CAD solution. One of the goals of the project at the time was to develop an extremely composable system (we wanted to be able to install plugins on the system, enriching its features).

We decided that each time an operation was performed, an event would be triggered. This way, plugins could be notified whenever an event of a certain type was triggered and were then able to perform related processing in a decoupled manner.

Points of attention on systems using event notifications

Loose coupling is great. However, it has a price that can be very high.

When we allow components to start listening for events in our application, it is easy to lose the track of what will happen.

In the CAD system I described above, we began to suffer from components that performed heavy processing in response to events, and the application often lost in responsiveness.

Distributed systems, which use event notifications, make some types of common operations (such as transactions) difficult to implement and especially to monitor.

It is important to remember that it is possible to achieve a good level of low coupling, too, by simply implementing asynchronous message exchange approaches (such as sending commands from one component to another using some messaging mechanism).

Takeaways

Implementing communication using event notifications is a powerful strategy to create louse coupled applications. Anyway, it is mandatory to design some kind of monitoring strategy to keep tracking of what is going on whenever an event is triggered.

Do you have any experience implementing event notifications? Share your thoughts in the comments.

Compartilhe este insight:

Comentários

Participe deixando seu comentário sobre este artigo a seguir:

Subscribe
Notify of
guest
0 Comentários
Inline Feedbacks
View all comments

AUTOR

Elemar Júnior
Fundador e CEO da EximiaCo atua como tech trusted advisor ajudando empresas e profissionais a gerar mais resultados através da tecnologia.

NOVOS HORIZONTES PARA O SEU NEGÓCIO

Nosso time está preparado para superar junto com você grandes desafios tecnológicos.

Entre em contato e vamos juntos utilizar a tecnologia do jeito certo para gerar mais resultados.

Insights EximiaCo

Confira os conteúdos de negócios e tecnologia desenvolvidos pelos nossos consultores:

Arquivo

Pós-pandemia, trabalho remoto e a retenção dos profissionais de TI

CTO Consulting e Especialista em Execução em TI
EximiaCo 2024 - Todos os direitos reservados
0
Queremos saber a sua opinião, deixe seu comentáriox
()
x

Muito obrigado!

Deu tudo certo com seu envio!
Logo entraremos em contato

Event Notifications

Para se candidatar nesta turma aberta, preencha o formulário a seguir:

Event Notifications

Para se candidatar nesta turma aberta, preencha o formulário a seguir:

Condição especial de pré-venda: R$ 14.000,00 - contratando a mentoria até até 31/01/2023 e R$ 15.000,00 - contratando a mentoria a partir de 01/02/2023, em até 12x com taxas.

Tenho interesse nessa capacitação

Para solicitar mais informações sobre essa capacitação para a sua empresa, preencha o formulário a seguir:

Tenho interesse em conversar

Se você está querendo gerar resultados através da tecnologia, preencha este formulário que um de nossos consultores entrará em contato com você:

O seu insight foi excluído com sucesso!

O seu insight foi excluído e não está mais disponível.

O seu insight foi salvo com sucesso!

Ele está na fila de espera, aguardando ser revisado para ter sua publicação programada.

Tenho interesse em conversar

Se você está querendo gerar resultados através da tecnologia, preencha este formulário que um de nossos consultores entrará em contato com você:

Tenho interesse nessa solução

Se você está procurando este tipo de solução para o seu negócio, preencha este formulário que um de nossos consultores entrará em contato com você:

Tenho interesse neste serviço

Se você está procurando este tipo de solução para o seu negócio, preencha este formulário que um de nossos consultores entrará em contato com você:

× Precisa de ajuda?