Building Apps around the Event Mesh

Understanding how to structure an application can be challenging. Different architectural patterns often lack insight into how to build day-to-day solutions that are often at least as complex as the business they operate in.

This solution pattern is written to make it obvious and to show simple, yet elegant, correct, and comprehensive way of building software, either in greenfield or even in legacy projects. This solution leverages the Red Hat OpenShift Serverless Eventing component, which implements the Event Mesh pattern.

Contributors: Chris Suszynski


Solution Patterns help you understand the art of the possible with Red Hat’s portfolio, and not intended to be used as is for production environments. You are welcome to use any part of this solution pattern for your own workloads.

1. Use cases

Event mesh pattern simplifies the operational complexity of distributed applications, making architectures more resilient and scalable.

Common use cases that can be addressed with this architecture include:

  • Correctness and consistency across distributed applications and services, without the hassles of Event Sourcing.

  • Modernising legacy applications by extracting smaller microservices into a distributed and eventually consistent system.

  • Enabling communication with external services, that can be easily tested using a common developer toolkit.

2. The story behind this solution pattern

Cabs is a fictional transportation company. Engineers at Cabs were struggling with their transactional-style, monolith application. They recently started an effort to modernize it.

The team saw a talk on Event Mesh. The talk presented the advantages of moving beyond transactional architectures in favor of eventual consistency. By leveraging event meshes with technologies like Knative, developers can achieve decoupled, reliable microservices without extensive re-engineering. This solution addresses inefficiencies and aligns distributed systems with real-world business processes. The team had figured out they could leverage the CQRS pattern together with Knative’s Event Mesh to modernize their application in a non-extrusive way.

3. The Solution

The core of this solution is an event mesh — a dynamic, flexible infrastructure layer that routes, retries, and processes asynchronous events across distributed components. Using Knative Eventing and CloudEvents, this pattern enables:

  • Reliable delivery of events with retry mechanisms.

  • Simplified asynchronous workflows.

  • Decoupling of services to improve scalability, testability and resilience.

The approach of Cabs engineering team is to extract well-defined services, using the CQRS pattern to identify Commands from Queries, and model the Commands as Events. Those events will be routed to the Event Mesh with regular HTTP messages. The CloudEvents library ensures the proper serialization of the events to and from the HTTP messages. The Event Mesh will handle not only the persistence of the events in-flight, but also all the required logic of retry in case of endpoint failure.