<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ravi R on Medium]]></title>
        <description><![CDATA[Stories by Ravi R on Medium]]></description>
        <link>https://medium.com/@raviir?source=rss-a3fe49cacdd6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cy-U0golCvIriPGQas6mGA.jpeg</url>
            <title>Stories by Ravi R on Medium</title>
            <link>https://medium.com/@raviir?source=rss-a3fe49cacdd6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:20:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raviir/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Mainframe to Event-Driven Architecture: Modernizing Enterprise Systems with the Strangler Fig…]]></title>
            <link>https://raviir.medium.com/from-mainframe-to-event-driven-architecture-modernizing-enterprise-systems-with-the-strangler-44868f6b7a7f?source=rss-a3fe49cacdd6------2</link>
            <guid isPermaLink="false">https://medium.com/p/44868f6b7a7f</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[debezium]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[mainframe-modernization]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <dc:creator><![CDATA[Ravi R]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 20:47:57 GMT</pubDate>
            <atom:updated>2026-11-20T21:34:46.929Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>From Mainframe to Event-Driven Architecture: Modernizing Enterprise Systems with the Strangler Fig and Transactional Outbox Patterns</strong></p><p><em>How we used Spring Boot, Embedded Debezium, Apache Kafka, PostgreSQL, and Snowflake to incrementally modernize a legacy mainframe ecosystem and eliminate traditional ETL batch jobs.</em></p><p>## Introduction</p><p>Modernizing a mission-critical mainframe application is rarely a straightforward technology migration.</p><p>Large enterprises often have decades of business logic embedded in monolithic mainframe applications. These systems process critical business transactions, integrate with numerous downstream applications, and support business operations that cannot simply be interrupted or rewritten overnight.</p><p>Replacing such systems introduces significant risks:</p><p>- Disrupting business-critical operations.<br>- Reimplementing decades of embedded business logic.<br>- Maintaining compatibility with existing downstream consumers.<br>- Preserving transaction ordering and data consistency.<br>- Coordinating application, database, and integration migrations.<br>- Managing the coexistence of legacy and modern applications.</p><p>Rather than attempting a complete rewrite, we explored a different approach: **incrementally extracting business capabilities from the mainframe while keeping the existing application operational.**</p><p>We combined the Strangler Fig Pattern with event-driven architecture, Change Data Capture (CDC), and the Transactional Outbox Pattern to create a modernization path that allowed new microservices to coexist with the legacy ecosystem.</p><p>The result was an architecture that enabled us to:</p><p>- Move order creation capabilities from the mainframe to microservices.<br>- Preserve integration with existing DB2 applications.<br>- Establish an event-driven communication architecture.<br>- Deliver database changes to Snowflake continuously.<br>- Deprecate multiple traditional nightly ETL jobs.<br>- Reduce dependencies on legacy batch processing.</p><p>Let’s walk through the architecture and some of the engineering challenges we encountered.</p><p>## 1. The Strangler Fig Pattern: Modernizing Without Rewriting the Mainframe</p><p>The Strangler Fig Pattern provides an incremental approach to replacing legacy applications.</p><p>Instead of rebuilding an entire monolithic application, we identify individual business capabilities and gradually move them into independently deployable services.</p><p>For our modernization initiative, the goal was to extract capabilities such as order creation into dedicated microservices without requiring immediate changes to the existing mainframe application.</p><p>The approach involved three stages.</p><p>Stage 1: Build new services**</p><p>We developed new Spring Boot microservices responsible for specific business capabilities.</p><p>These services were designed independently of the mainframe application, with their own application logic and PostgreSQL persistence layer.</p><p>Stage 2: Maintain legacy compatibility**</p><p>During the transition, existing mainframe applications continued to operate against DB2.</p><p>The new services were introduced alongside the existing applications, with integration mechanisms established to maintain compatibility with legacy consumers.</p><p>This avoided requiring a large-scale mainframe application rewrite before introducing new capabilities.</p><p>Stage 3: Gradually migrate business ownership**</p><p>As new services matured, business functionality was progressively moved away from the mainframe.</p><p>For example, order creation was transitioned from the mainframe application to a dedicated order microservice.</p><p>The important architectural decision was to separate the modernization of business capabilities from the modernization of the underlying legacy infrastructure.</p><p>We could modernize one capability at a time without disrupting the rest of the monolith.</p><p>## 2. Establishing an Event-Driven Architecture</p><p>Moving business capabilities into microservices introduces a new challenge: how do these services communicate reliably with other applications and enterprise systems?</p><p>Traditional point-to-point integrations and scheduled batch jobs create tight coupling and operational dependencies.</p><p>We wanted a more scalable approach.</p><p>We introduced Apache Kafka as the central event streaming platform and Debezium as the Change Data Capture engine.</p><p>The architecture used the following technologies:</p><p>| Component | Technology |<br>| — -| — -|<br>| Microservices | Java, Spring Boot |<br>| Operational database | PostgreSQL |<br>| Change Data Capture | Embedded Debezium |<br>| Event streaming | Apache Kafka (AWS MSK) |<br>| Analytics platform | Snowflake |<br>| Data ingestion | Custom Spring Boot Kafka consumers |</p><p>### High-level architecture</p><p>The following diagram illustrates the primary architecture and integration paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TOeGg4iU6bMgemhkoMkFig.png" /></figure><p>The key architectural principle was simple:</p><p>**Applications write to their operational databases. Debezium captures committed database changes and publishes them to Kafka. Downstream consumers independently process those events based on their business requirements.**</p><p>This separated transaction processing from downstream integration and analytics.</p><p>## 3. Transactional Outbox Pattern: Reliable Communication with the Mainframe</p><p>One of the most interesting challenges in this modernization was maintaining reliable communication between the new microservices and existing mainframe applications.</p><p>Moving order creation into a microservice did not mean that all dependent mainframe applications could immediately be retired.</p><p>Some downstream processes still depended on data being written to multiple DB2 tables.</p><p>We needed a reliable mechanism to propagate business transactions back to the mainframe.</p><p>This is where the Transactional Outbox Pattern became important.</p><p>### The problem with traditional event publishing</p><p>Consider a microservice that performs two operations:</p><p>1. Writes an order into PostgreSQL.<br>2. Publishes an event to Kafka.</p><p>These are two independent operations.</p><p>What happens if the database transaction succeeds but Kafka publishing fails?</p><p>The order exists in PostgreSQL, but downstream consumers never receive the event.</p><p>The opposite situation can also create inconsistencies: an event may be published even though the database transaction eventually fails.</p><p>We needed to eliminate this dual-write problem.</p><p>### Our approach: Transactional Outbox</p><p>We introduced outbox tables alongside the regular application tables in PostgreSQL.</p><p>When the order microservice processes a business transaction, it writes both the business data and the corresponding outbox event within the same database transaction.</p><p>For example:</p><p>```text<br>BEGIN TRANSACTION</p><p>INSERT INTO orders (…);</p><p>INSERT INTO outbox_events (<br> event_id,<br> aggregate_id,<br> event_type,<br> payload,<br> created_at<br>);</p><p>COMMIT;<br>```</p><p>The important aspect is that both writes succeed or fail together.</p><p>Debezium monitors the PostgreSQL transaction log and captures the committed changes from the outbox table.</p><p>It then publishes the corresponding events to Kafka.</p><p>The event contains the information required by downstream consumers, including the event type and business payload.</p><p>### Writing back to DB2</p><p>Once the event is available in Kafka, a dedicated consumer processes it and performs the required writes to DB2.</p><p>This allowed us to support legacy integration without introducing direct database dependencies into the new order microservice.</p><p>The flow looks like this:</p><p>```<br>Order Microservice<br> |<br> v<br>PostgreSQL Transaction<br> |<br> + — — Order Tables<br> |<br> + — — Outbox Tables<br> |<br> v<br> Debezium CDC<br> |<br> v<br> Kafka<br> |<br> v<br> Mainframe Integration<br> Consumer<br> |<br> v<br> Multiple DB2 Tables<br>```</p><p>This approach provided several advantages:</p><p>- The microservice did not need to know the internal DB2 table structures.<br>- Mainframe integration was decoupled from order processing.<br>- Events could be independently consumed and processed.<br>- The integration layer could evolve without changing the order microservice.<br>- The same event could support multiple downstream integrations.</p><p>It also created a foundation for eventually reducing the number of direct dependencies on the mainframe.</p><p>An important implementation consideration is that the outbox pattern provides atomicity between the business transaction and event creation, but not automatic exactly-once delivery across PostgreSQL, Kafka, and DB2. Consumers must be designed for retries and idempotent processing.</p><p>## 4. Preserving Event Ordering in Kafka</p><p>Another significant engineering challenge was maintaining the correct processing sequence.</p><p>In enterprise systems, database changes are not always independent.</p><p>For example, an order might involve multiple related records:</p><p>- Order creation.<br>- Order details.<br>- Related child records.<br>- Subsequent order updates.</p><p>Processing these events out of sequence can lead to inconsistent downstream state.</p><p>We needed to ensure that related changes were processed in the correct order.</p><p>### Why Kafka partitioning matters</p><p>Kafka guarantees ordering within a partition, not across multiple partitions.</p><p>If related events are distributed across different partitions, consumers may process them in different sequences.</p><p>To address this, we designed the event routing strategy to send the changes requiring sequential processing to the same Kafka topic and partition.</p><p>This ensured that Kafka preserved their ordering within that partition.</p><p>The distinction is important: sending events to the same topic alone is not sufficient. They must also be routed to the same partition, with an appropriate ordering strategy.</p><p>For our workload, this was a critical architectural consideration because downstream consumers depended on the sequence of database changes.</p><p>The design required balancing ordering guarantees against consumer parallelism and throughput.</p><p>## 5. Building a Real-Time Data Pipeline to Snowflake</p><p>Traditionally, many enterprise applications rely on nightly ETL jobs to move operational data into analytical platforms.</p><p>These jobs extract data from source systems, transform it, and load it into data warehouses on a scheduled basis.</p><p>While this approach works, it introduces several limitations:</p><p>- Analytics data is available only after batch execution.<br>- Large extraction jobs consume database resources.<br>- Batch failures can delay downstream reporting.<br>- Multiple ETL jobs create operational dependencies.<br>- Maintaining hundreds of data pipelines becomes increasingly complex.</p><p>Since we already had database changes flowing into Kafka through Debezium, we wanted to leverage the same event stream for analytics.</p><p>Instead of building separate extraction pipelines, we introduced a dedicated Kafka consumer responsible for writing changes into Snowflake.</p><p>### Micro-batch processing</p><p>The Snowflake consumer reads raw change events from Kafka and processes them in batches.</p><p>Rather than issuing an individual Snowflake operation for every event, the consumer groups events and performs micro-batch processing.</p><p>The high-level flow is:</p><p>```text<br>PostgreSQL<br> |<br> v<br>Embedded Debezium<br> |<br> v<br>Kafka<br> |<br> v<br>Snowflake Kafka Consumer<br> |<br> v<br>Batch Processing<br> |<br> v<br>Snowflake Staging Tables<br> |<br> v<br>MERGE / Upsert<br> |<br> v<br>Snowflake Target Tables<br>```</p><p>This approach significantly reduces the overhead associated with individual database operations.</p><p>It also provides a more continuous data ingestion model compared with traditional nightly ETL.</p><p>One important design consideration is checkpoint management. Kafka offsets should be committed only after the corresponding Snowflake writes have been durably completed. This allows the consumer to recover safely from failures without silently losing events.</p><p>With this architecture, Kafka became the common integration layer for both operational applications and analytical consumers.</p><p>## 6. Raw Events vs. Materialized Events</p><p>Another interesting aspect of the architecture was that not every Kafka consumer needed the same representation of the data.</p><p>We had two distinct categories of consumers.</p><p>### Raw CDC events</p><p>Raw events represented the underlying database changes captured by Debezium.</p><p>These events were primarily consumed by the Snowflake ingestion pipeline.</p><p>The consumer processed database-level changes and applied them to analytical tables.</p><p>This provided a consistent mechanism for replicating operational data into Snowflake without building individual extraction jobs for every table.</p><p>### Materialized business events</p><p>Not every downstream application needs to understand database-level CDC events.</p><p>Application services generally care about business events rather than individual row changes.</p><p>For example:</p><p>- An order has been created.<br>- An order has been updated.<br>- A business process has completed.<br>- A related service needs to perform additional processing.</p><p>We therefore used materialized business events for application-level integrations.</p><p>These events were consumed by other applications to support:</p><p>- Event notifications.<br>- Cross-microservice communication.<br>- Business process coordination.<br>- Downstream application workflows.</p><p>This separation was important.</p><p>Raw CDC events provided a representation of database changes, while materialized events provided a representation of business-level activity.</p><p>It allowed analytical consumers and application consumers to evolve independently.</p><p>It also avoided forcing every application to understand the underlying database schema.</p><p>## 7. Embedded Debezium: Operational Challenges</p><p>We chose Embedded Debezium with Spring Boot rather than treating CDC as an entirely separate integration platform.</p><p>This gave us greater control over the CDC lifecycle and allowed us to integrate change capture directly into our Spring Boot-based streaming application.</p><p>However, embedded CDC introduced some operational considerations.</p><p>### Managing CDC offsets and Kafka publishing</p><p>With embedded Debezium, the application owns the lifecycle of the connector and its offset management.</p><p>One important requirement was ensuring that database changes consumed by Debezium were successfully published to Kafka before the application considered the corresponding source progress complete.</p><p>We had to pay particular attention to:</p><p>- Debezium offset management.<br>- Kafka producer acknowledgments.<br>- Connector lifecycle management.<br>- Error handling and retry behavior.<br>- Application restart and recovery.</p><p>### Graceful shutdown</p><p>One of the most important operational challenges was application shutdown.</p><p>A Spring Boot application can receive a shutdown signal while Debezium is processing database changes or Kafka is still publishing messages.</p><p>Simply terminating the application could interrupt in-flight processing.</p><p>We implemented graceful shutdown handling to coordinate the shutdown sequence.</p><p>The objective was to:</p><p>1. Stop accepting new processing work.<br>2. Allow in-flight CDC processing to complete.<br>3. Flush pending Kafka producer records.<br>4. Ensure the corresponding source offsets are safely persisted.<br>5. Close the Debezium connector and supporting resources.</p><p>This was particularly important during Kafka restarts, application deployments, and infrastructure maintenance.</p><p>The key lesson was that embedded CDC is not simply about reading database changes. It also requires careful management of application lifecycle, Kafka delivery guarantees, and recovery semantics.</p><p>## 8. Deprecating Legacy ETL and Nightly Batch Jobs</p><p>One of the most meaningful outcomes of this architecture was the ability to retire multiple traditional nightly ETL jobs.</p><p>Previously, operational data had to be extracted through scheduled batch processes before downstream analytical systems could consume it.</p><p>With Debezium and Kafka in place, we already had a continuous stream of database changes.</p><p>Rather than maintaining separate extraction mechanisms, we reused this event stream to feed Snowflake.</p><p>This changed the integration model from:</p><p>**Traditional architecture**</p><p>```text<br>Operational Database<br> |<br> v<br> Nightly ETL<br> |<br> v<br> Transformation<br> |<br> v<br> Snowflake<br>```</p><p>To:</p><p>**Event-driven architecture**</p><p>```text<br>Operational Database<br> |<br> v<br> Debezium CDC<br> |<br> v<br> Kafka<br> |<br> v<br> Micro-batch Consumer<br> |<br> v<br> Snowflake<br>```</p><p>This eliminated the need for multiple legacy extraction workflows and reduced dependencies on scheduled batch processing.</p><p>It also established a reusable ingestion architecture.</p><p>New downstream consumers could subscribe to Kafka events rather than requiring another independent ETL implementation.</p><p>## 9. Key Architectural Benefits</p><p>The modernization delivered benefits across application architecture, integration, and data engineering.</p><p>| Area | Architectural improvement |<br>| — -| — -|<br>| Mainframe modernization | Incremental extraction of business capabilities |<br>| Application architecture | Independent Spring Boot microservices |<br>| Database integration | Transactional Outbox Pattern |<br>| Event streaming | Centralized Kafka event backbone |<br>| Data consistency | Transactional event creation and idempotent consumers |<br>| Event ordering | Partition-aware sequential processing |<br>| Analytics | Continuous CDC-driven Snowflake ingestion |<br>| ETL modernization | Deprecation of multiple nightly batch jobs |<br>| Integration | Independent raw and business-event consumers |<br>| Operations | Managed CDC lifecycle and graceful shutdown |</p><p>More importantly, we avoided making the mainframe modernization dependent on a complete rewrite.</p><p>We could incrementally move functionality while preserving compatibility with existing systems.</p><p>## 10. Lessons Learned</p><p>There are several lessons from implementing this architecture that are worth highlighting.</p><p>**1. Modernization does not require a big-bang migration.**</p><p>The Strangler Fig Pattern allowed us to move individual capabilities out of the monolith without disrupting the entire application ecosystem.</p><p>**2. Database changes can become an enterprise integration platform.**</p><p>Debezium and Kafka provided a reusable mechanism for distributing changes to multiple downstream consumers.</p><p>**3. The Transactional Outbox Pattern is essential for reliable service integration.**</p><p>It addressed the dual-write problem and allowed new microservices to communicate with legacy applications without tightly coupling application logic to DB2.</p><p>**4. Event ordering must be designed, not assumed.**</p><p>Kafka partitioning, event keys, and consumer behavior must align with business transaction requirements.</p><p>**5. CDC requires operational engineering.**</p><p>Embedded Debezium introduced lifecycle management, offset handling, producer flushing, and graceful shutdown requirements that are just as important as the actual CDC implementation.</p><p>**6. Analytics does not always need another ETL pipeline.**</p><p>When database changes are already available through CDC, the same event stream can support analytical ingestion and application integrations.</p><p>— -</p><p>## Conclusion</p><p>Modernizing a legacy mainframe ecosystem is as much an architectural challenge as it is a technology challenge.</p><p>Our approach combined the Strangler Fig Pattern, Transactional Outbox Pattern, Debezium, Apache Kafka, PostgreSQL, and Snowflake to establish an incremental modernization strategy.</p><p>We successfully moved order creation capabilities from the mainframe into microservices, maintained integration with existing DB2 applications, established an event-driven communication architecture, and deprecated multiple nightly ETL batch jobs.</p><p>Perhaps the most important takeaway is that **the path to modernizing a mainframe does not necessarily begin by replacing the mainframe. It can begin by changing how the systems around it communicate.**</p><p>By introducing CDC-driven event streaming and decoupling business capabilities, organizations can gradually transition from monolithic architectures toward independently deployable, event-driven systems without requiring a disruptive rewrite.</p><p>The Strangler Fig Pattern provides the migration strategy. The Transactional Outbox Pattern provides reliable integration. Debezium and Kafka provide the event backbone.</p><p>Together, they create a practical foundation for enterprise modernization.</p><p>— -</p><p>**Technology Stack**</p><p>- Java and Spring Boot<br>- Embedded Debezium<br>- Apache Kafka / AWS MSK<br>- PostgreSQL<br>- Snowflake<br>- IBM DB2 / z/OS</p><p>**Topics:** Mainframe Modernization, Strangler Fig Pattern, Transactional Outbox Pattern, Debezium, Apache Kafka, Change Data Capture, Event-Driven Architecture, Snowflake, Data Engineering, Microservices.</p><p>cdc-streamer on Github: <a href="https://github.com/raviii4u/pg-kafka-snowflake-streamer">https://github.com/raviii4u/pg-kafka-snowflake-streamer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44868f6b7a7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>