October 26, 2026
Use of architectural patterns to ensure reliability in messaging-based asynchronous integrations
Alvaro Queiroz Valente da Sllva; Carlos Henrique Rodrigues Sarro
DOI: 10.22167/2675-6528-202600519
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
The growing adoption of distributed architectures and system integrations in digital transformation processes has increased the importance of reliability in asynchronous messaging-based communications, due to the inherent risks of failures, redeliveries, and inconsistencies. The study analyzed how architectural patterns influenced the increase in reliability in asynchronous system integrations, considering the role of non-functional requirements in architectural decisions. The research adopted a mixed approach, combining a literature review with the development of an experimental proof of concept based on microservices, using RabbitMQ, PostgreSQL, and resilience mechanisms. In the experimental stage, a controlled campaign of 1,000 requests was executed, distributed among the main flow, transient failures, persistent failures, message redeliveries, and compensations. The results demonstrated that reliability did not depend on a single mechanism, but on the combination of patterns such as Transactional Outbox, idempotent consumer, Retry with backoff and jitter, Circuit Breaker, Bulkhead, Dead Letter Queue, message durability, and Saga with compensation, which preserved the integrity of the business flow even in adverse scenarios. It was concluded that reliability is a central non-functional requirement in asynchronous integrations, requiring explicit architectural decisions, guided by operational risks and the criticality of the business domain.
Keywords: Reliability; Messaging; Microservices; Architectural patterns; Non-functional requirements.
1. Introduction
Digital transformation has significantly increased organizations’ dependence on the use of information systems, which have come to support operational processes, strategic decisions, and increasingly integrated business flows. In this scenario, systems integration has become one of the central themes of software engineering, as companies need to connect legacy systems, enterprise platforms, and modern applications developed with service-oriented architectures and microservices (BRYNJOLFSSON; MCAFEE, 2014; SOMMERVILLE, 2011). This technological heterogeneity demands solutions capable of promoting interoperability, consistent data exchange, and the continuity of organizational processes (BASS; CLEMENTS; KAZMAN, 2012).
With the evolution of distributed, decentralized, and dynamic architectures, the complexity of integrations has increased significantly. Although this architectural model has provided benefits such as scalability, flexibility, and independent evolution of components, it has also increased the number of interactions between systems and, consequently, the potential points of failure (DRAGONI et al., 2017; KLEPPMANN, 2017). In corporate environments, system integration failures can compromise data consistency, interrupt critical processes, and generate operational and financial impacts, making system integration not only a technical issue but also a strategic factor for good organizational performance (FOWLER, 2002; BASS; CLEMENTS; KAZMAN, 2012).
In this context, non-functional requirements play a decisive role in architectural choices. While functional requirements describe what the system should do, non-functional requirements define quality attributes, constraints, and operating conditions, such as performance, availability, scalability, security, and reliability (CHUNG; LEITE, 2009; SOMMERVILLE, 2011). Among these attributes, reliability stands out for representing the system’s ability to operate correctly over time and maintain expected functionality even in the face of failures, an aspect particularly relevant in distributed systems, where failure must be treated as an inherent condition of the computational environment (KLEPPMANN, 2017).
In response to the demands for scalability and decoupling, messaging-based asynchronous integrations have become widely adopted in the construction of modern systems. This model allows information producers and consumers to operate independently, favoring resilience, elasticity, and better utilization of computational resources (DRAGONI et al., 2017). However, although asynchronous communication offers several advantages, it also introduces specific challenges to the issue of reliability, such as guaranteeing message delivery, handling duplicates, maintaining processing order, flow traceability, and consistent handling of distributed failures (HOHPE; WOOLF, 2004; KLEPPMANN, 2017).
Technical and academic literature has recognized the importance of architectural patterns to address these problems, especially in integration scenarios between distributed systems (BASS; CLEMENTS; KAZMAN, 2012; FOWLER, 2002). Nevertheless, the application of these patterns does not always occur systematically in organizations, which can lead to the adoption of empirical, fragile, and difficult-to-maintain solutions. This gap justifies the need to understand how architectural patterns can support more consistent decisions in the design of asynchronous integrations, especially when guided by non-functional requirements and the criticality of business flows (CHUNG; LEITE, 2009; KLEPPMANN, 2017).
Therefore, this research is justified by the need to improve the reliability of asynchronous system integrations, which are crucial for the continuity and consistency of business operations in modern distributed environments. In this context, the objective of this work was to analyze how the application of architectural patterns could contribute to ensuring reliability in asynchronous system integrations, considering the influence of non-functional requirements on architectural decisions.
2. Material and Methods
The methodology employed in this study adopted a mixed approach, combining a literature review with the development of an experimental proof of concept. The objective was to generate practical knowledge in software engineering, aiming to improve the reliability of asynchronous integrations in distributed systems environments. The research was structured in two main stages. In the first, an instrumental literature review was conducted to select quality attributes and architectural patterns relevant to reliability, based on the premise that architectural decisions directly influence attributes such as reliability, availability, resilience, and observability (BASS; CLEMENTS; KAZMAN, 2012; CHUNG; LEITE, 2009).
The second stage consisted of the development of a proof of concept, a system project designed to reproduce, in a controlled environment, a distributed flow subject to typical failures of asynchronous integrations. The purpose was to apply and observe the behavior of the architectural patterns identified in the literature review, seeking to produce knowledge oriented towards the solution of a practical software engineering problem. The experimental environment was implemented using Java 21, with the Spring Boot (version 3.3.4), Spring AMQP (version 3.1.7), and Resilience4j (version 2.2.0) frameworks.
The messaging infrastructure employed RabbitMQ (version 3.13), and the PostgreSQL database (version 18) was used for persistence. All components were orchestrated in a local environment using Docker Compose. The solution was developed with three microservices: order-service, inventory-service, and payment-service. The order-service received order requests, persisted the data, and initiated the distributed flow. The inventory-service managed stock reservation and compensatory release, while the payment-service processed payments and simulated failures. Communication between these services occurred asynchronously, mediated by messages exchanged in RabbitMQ. PostgreSQL was used for persisting business data, outbox state, processed message control, and compensation flow states.
In the main flow of the proof of concept, the order-service received a request, persisted the order, and registered an order.created event in the outbox. A publisher component emitted the event to the broker. Then, the inventory-service consumed the event, performed the stock reservation, and published stock.reserved. Finally, the payment-service consumed the reservation message, processed the payment, and published payment.approved or payment.failed, updating the order to PAID or CANCELLED states, triggering stock compensation in case of definitive failure. To ensure reliability, the following patterns were implemented: Transactional Outbox, idempotent consumer, Retry with backoff and jitter, Circuit Breaker, Bulkhead, Dead Letter Queue, message persistence, at-least-once semantics, and Saga with compensation. These patterns were applied to ensure atomicity, neutralize duplicates, reprocess transient failures, interrupt attempts on persistent failures, limit concurrency, isolate invalid messages, reinforce durability, and restore eventual system consistency in cancellation flows.
The experimental evaluation was conducted through a controlled test campaign, which involved executing 1,000 order creation requests, using Grafana K6 (version 1.61) and GO (version 1.25). The requests were distributed across scenarios of successful main flow, transient payment failures (recovered by retry), and persistent failures (resulting in cancellation and stock compensation). Additionally, message redeliveries were simulated and invalid messages were injected, forwarded to the DLQ. Circuit Breaker opening occurrences were also observed.
The variables observed in the experimental campaign included processed, successfully completed, and canceled orders, additional reprocessing attempts, message redeliveries, neutralized duplicates, messages sent to the DLQ, compensations executed, and inconsistencies between the state persisted in the database and the published events. Evidence collection was carried out through microservice logs, inspection of queues and exchanges in RabbitMQ, and querying tables persisted in PostgreSQL. A dashboard was developed to visualize execution data and simulations, allowing for the monitoring of business flow and the application of design patterns.
3. Results and Discussion
The experimental campaign conducted, involving 1,000 order creation requests in a microservices environment, demonstrated the effectiveness of the proposed architecture in fault management and maintaining business flow integrity. The results indicated that 950 orders were successfully completed, while 50 were controlled closures, resulting in a success rate of 95.0% and a cancellation rate of 5.0%. In all cancellation cases, the compensatory flow was triggered to reverse the previously made stock reservation. Notably, no inconsistency was observed between the persisted order state and the published events, reinforcing the importance of the Transactional Outbox pattern in mitigating the *dual write* problem.
These findings corroborate the premise that reliability in asynchronous integrations is not an automatic consequence of using messaging, but rather a systemic property that results from the combined application of architectural patterns. The implemented architecture demonstrated the ability to handle failures in different layers of the distributed flow, highlighting the need for explicit mechanisms to ensure delivery, controlled reprocessing, deduplication, and compensation. This approach aligns with the perspective of Bass, Clements, and Kazman (2012) and Richards and Ford (2020), who emphasize the relevance of conscious architectural decisions, guided by domain criticality and operational risks.
Architectural Patterns for Reliability in Asynchronous Integrations
In the proof of concept, several architectural patterns were synergistically implemented to ensure the reliability of asynchronous messaging-based integrations. The Transactional Outbox pattern was applied in the `order-service` to ensure atomicity between database writes and event publishing. By recording the order and the `order.created` event within the same database transaction, the risk of inconsistency between the locally persisted state and the asynchronous message was significantly reduced, addressing the challenge of the *dual write problem* in distributed systems (Richardson, 2019; Kleppmann, 2017).
The *at-least-once* delivery semantics were adopted to prioritize message non-loss, even if this implied the possibility of redeliveries. To manage this characteristic securely, an idempotent consumer was implemented, which used a processed messages table to register and verify the uniqueness of each event. This mechanism allowed the system to accept redeliveries without duplicating stock reservations, status updates, or compensations, neutralizing unwanted side effects and ensuring flow consistency (Kleppmann, 2017; Hohpe; Woolf, 2004).
In the `payment-service`, the Retry pattern with *backoff* and *jitter* was crucial for reprocessing transient failures. This mechanism allowed for automatic recovery from momentary instabilities, such as temporary service unavailability or network issues, without the need for manual intervention. The use of progressively larger intervals between retries (*backoff*) and the introduction of temporal variation (*jitter*) was essential to avoid access synchronization and overload of an already degraded system, contributing to the stabilization of the service ecosystem (Adkins et al., 2020; Bellemare, 2020).
In addition to Retry, the Circuit Breaker pattern acted as an isolation mechanism for persistent failures. Upon identifying that the failure rate exceeded a configured threshold, the breaker would open, causing subsequent calls to fail instantly, a behavior known as *fail-fast*. This pattern prevented the continuous reprocessing of messages from overloading a persistently unavailable or slow remote service, preventing the cascade failure effect and increasing resilience in asynchronous architectures (Richards; Ford, 2020).
The Bulkhead pattern was implemented to limit the propagation of failures and excessive resource consumption. Inspired by the design of watertight compartments in ships, it separated message consumers into resource *pools*, such as *threads* or connections. This ensured that resource exhaustion caused by a high volume or recurring failures in a specific type of message would not affect the system’s total capacity to process other messages, strengthening the platform’s overall resilience (Bass; Clements; Kazman, 2012; Adkins et al., 2020).
Message persistence was a fundamental pillar of reliability, requiring the message broker to write the message to non-volatile storage immediately after receiving it from the producer. Durable queues and persistent messages were employed to protect against losses in case of broker server failure, ensuring the delivery and integrity of the business flow, as highlighted by Kleppmann (2017). This measure ensured that critical events were not lost in situations of messaging system unavailability.
To isolate problematic messages that could not be processed successfully, the Dead Letter Queue (DLQ) pattern was configured. Messages that exceeded a reprocessing attempt limit were diverted from the main flow, preserving the continuity of processing for other messages. The DLQ functioned as an exception channel, creating an operational control point for diagnosis and supervised reprocessing, preventing a single “problematic” event from paralyzing the message flow (Hohpe; Woolf, 2004; Bellemare, 2020).
Finally, the Saga pattern with compensation was implemented in the cancellation flow to ensure eventual consistency in distributed transactions. When a step in the business flow failed, compensatory measures were triggered to reverse previous effects and restore the system to a valid final state. This pattern ensured that, even in the event of definitive payment failure, the order would be canceled and the stock reservation undone, maintaining the integrity of the business process (Richardson, 2019; Kleppmann, 2017; Bellemare, 2020).
Experimental Planning and Execution Scenarios
The controlled experimental campaign involved 1,000 order creation requests, executed with the Grafana K6 tool. The requests were distributed into three behavior groups to simulate different failure and recovery scenarios. The first group, with 810 requests, represented the successful main flow, where the order, stock reservation, and payment were completed without issues. This scenario validated the nominal execution of the distributed flow, demonstrating the architecture’s ability to process transactions without failures.
The second group, composed of 140 requests, simulated transient payment failures. In these cases, the Retry mechanism with *backoff* and *jitter* recovered the processing, resulting in the successful completion of the operation without manual intervention. 308 additional processing attempts were observed across the transient and persistent failure scenarios, demonstrating the operational cost of *retry*, but also its effectiveness in recovery, as discussed by Adkins et al. (2020), who emphasize the importance of configuring these mechanisms with containment.
The third group, with 50 requests, represented persistent payment failures. In these situations, the flow was terminated with the cancellation of the order and the activation of stock compensation. In all 50 cases, stock compensation was successfully completed, ensuring eventual system consistency. The absence of inconsistencies between the database state and the published events reinforced the effectiveness of the Transactional Outbox and the Saga pattern with compensation, which ensured data integrity even in the face of definitive failures.
In addition to business scenarios, specific failure events were introduced to observe the behavior of reliability patterns. 42 message redeliveries were simulated, exercising the *at-least-once* semantics and idempotent consumer behavior. It was confirmed that duplication was neutralized without causing side effects, such as undue repetition of stock reservations. Additionally, 8 invalid messages were injected and, after exhausting processing attempts, were correctly routed to the DLQ, demonstrating the system’s ability to isolate problems and maintain the continuity of the main flow.
During the experimental campaign, 11 occurrences of Circuit Breaker opening were recorded, demonstrating its action in containing repeated calls to a persistently degraded payment component. This behavior prevented the system from insisting on unviable operations, reducing the risk of cascading failures and protecting the platform’s integrity. The Bulkhead, in turn, limited resource consumption, preventing localized degradation from compromising the entire integration system, ensuring that slowness in one flow did not affect other services.
Interpretive Synthesis of Findings
The analysis of the proof-of-concept results reinforces that reliability in asynchronous integrations is a non-functional requirement that demands a multifaceted and deliberate architectural approach. The strategic combination of patterns such as Transactional Outbox, idempotent consumer, Retry with backoff and jitter, Circuit Breaker, Bulkhead, Dead Letter Queue, message durability, and Saga with compensation was essential to preserve the integrity of the business flow in various failure scenarios. Each pattern acted on a specific layer, contributing to the overall system resilience and recovery capability.
The Transactional Outbox ensured reliable event publication, mitigating critical inconsistencies between the persisted state and emitted messages. The *at-least-once* semantics, combined with the idempotent consumer, ensured that no messages were lost and that redeliveries did not cause unwanted side effects, such as duplicated operations. Retry with *backoff* and *jitter* allowed for automatic recovery from transient failures, while Circuit Breaker and Bulkhead isolated and contained persistent failures, protecting the system against cascading degradations and resource exhaustion, respectively.
A Dead Letter Queue proved to be an effective mechanism for isolating problematic messages, maintaining the fluidity of the main processing and offering an operational control point for supervised reprocessing. Message durability, in turn, ensured protection against losses in case of *broker* failure, guaranteeing event persistence. Finally, the Saga pattern with compensation enabled eventual consistency in distributed flows, allowing the system to reach a valid final state even after failures in intermediate steps, through compensatory actions.
The results also highlighted the inherent *trade-offs* in architectural decisions. The *retry*, while effective in recovery, increased the number of attempts and, consequently, the operational cost of the flow. The *outbox* reduced inconsistencies but added an asynchronous publishing component and greater operational complexity. The choice of *at-least-once* semantics preserved delivery but required the implementation of explicit deduplication. These *trade-offs* reinforce the need for architectural decisions to be guided by domain criticality, business risks, and prioritized non-functional requirements, as pointed out by Bass, Clements, and Kazman (2012) and Richards and Ford (2020). Reliability, therefore, is a deliberate construct that requires the conscious articulation of resilience and failure handling mechanisms, adapted to the specific application context.
4. Conclusion
This study analyzed how the application of architectural patterns could contribute to ensuring reliability in asynchronous system integrations, considering the influence of non-functional requirements on architectural decisions. It was verified, through an experimental proof of concept, that reliability was not established as an automatic consequence of using messaging, but rather as a systemic property resulting from the deliberate combination of various patterns. The experimental campaign, which involved 1,000 requests, demonstrated that the articulation of mechanisms such as Transactional Outbox, idempotent consumer, Retry with backoff and jitter, Circuit Breaker, Bulkhead, Dead Letter Queue, message durability, and Saga with compensation was crucial for preserving business flow integrity. It was observed that the Transactional Outbox mitigated inconsistencies between the persisted state and event publication, while the idempotent consumer neutralized duplicities arising from the at-least-once delivery semantics. Retry with backoff and jitter allowed for the recovery of transient failures, and the Circuit Breaker, along with the Bulkhead, contained the propagation of persistent failures and resource exhaustion. The Dead Letter Queue isolated problematic messages, and the Saga pattern with compensation ensured the consistent completion of distributed processes, even in adverse scenarios. The main contribution of this work lies in the practical demonstration that reliability in asynchronous integrations requires explicit architectural decisions, guided by operational risks and business domain criticality.
The results also highlighted the trade-offs inherent in architectural choices, such as the increased operational cost of retries and the additional complexity introduced by the outbox pattern, which, however, were compensated by greater predictability and consistency of the flow. For future work, it is recommended to expand the proof of concept to scenarios closer to production environments, with a higher volume of messages and simultaneous failures, in order to deepen the analysis of resilience at scale. It is also suggested to compare the analyzed architectural patterns with other messaging and persistence approaches, evaluating differences in reliability, performance, and operational complexity. Future studies may also incorporate detailed observability and reliability engineering metrics, such as recovery time and redelivery volume. Finally, applying the proposed architecture to other business domains with high transactional criticality can enrich the understanding of the trade-offs involved in architectural decisions.
Bibliographic References
BASS, L.; CLEMENTS, P.; KAZMAN, R. Software Architecture in Practice. 3. ed. Boston: Addison-Wesley,
BASS, L.; CLEMENTS, P.; KAZMAN, R. Software Architecture in Practice. 3. ed. Boston: Addison-Wesley, 2012.
BRYNJOLFSSON, E; MCAFEE, A. A segunda era das máquinas: trabalho, progresso e prosperidade em uma época de tecnologias extraordinárias. Rio de Janeiro: Alta Books, 2014.
CHUNG, L.; LEITE, J. C. S. P. On Non-Functional Requirements in Software Engineering. In: Conceptual Modeling: Foundations and Applications. Berlin: Springer, 2009.
DRAGONI, N. et al. Microservices: Yesterday, Today, and Tomorrow. In: Present and Ulterior Software Engineering. Cham: Springer, 2017.
FOWLER, M. Patterns of Enterprise Application Architecture. Boston: Addison-Wesley, 2002.
HOHPE, G.; WOOLF, B. Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions. Boston: Addison-Wesley, 2004.
KLEPPMANN, M. Designing Data-Intensive Applications. Sebastopol: O’Reilly Media, 2017.
SOMMERVILLE, I. Software Engineering. 9. ed. Boston: Addison-Wesley, 2011.
Article originating from the Final Course Work of the Specialization in Software Engineering of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform