Breaking free of the legacy straitjacket - modernizing insurance systems

Avatar of Rohit Bhat Rohit Bhat, Manager, Engineering

SageSure’s growth story has been phenomenal, and it has been a challenge for our applications to keep up with business expansion. Early on, SageSure invested in building applications based on relational database (RDBMS) technology. Core policy functions like quoting, binding, policy administration, endorsements, and billing relied on a tapestry of stored procedures, triggers, and application-level code. A few years back our engineering team identified Temporal Workflows as a powerful solution in modernizing our intricate, stateful business processes.

Challenges of RDBMS-driven workflows

The growth in our business has introduced specific complexities that exacerbates the pain points of traditional RDBMS-managed workflows:

Enter Temporal: durable execution

Temporal is an open-source, distributed system that enables us to write durable, fault-tolerant, and scalable workflows as code. Instead of relying on a database for state management and orchestration, Temporal provides a dedicated platform that ensures our workflow executions are:

Legacy services migration

Migrating the intricate, stateful processes within our legacy RDBMS based applications to Temporal typically involves identifying and extracting the core business processes currently orchestrated within the database and application code. Here’s our conceptual approach:

Example: policy payment processing workflow using Java

Sample code.

Temporal Batch Iterator pattern for large-scale data processing

One of the most challenging aspects of migrating our legacy insurance systems is dealing with vast amounts of existing data that needs to be processed, for example, monthly statement generation. Traditionally, this involved complex, fragile batch jobs, often orchestrated via database agent or custom scripts, which are prone to failure and difficult to monitor.

Temporal’s Batch Iterator Pattern provides a powerful, durable, and observable way to handle these large-scale data processing tasks. Instead of trying to process a large dataset within a single, long-running workflow, the pattern works as follows:

The Batch Iterator pattern is ideal for tasks like:

Sequence diagrams illustrating the Batch Iterator Pattern:

Sequence diagram of Orchestrator Workflow.

Explanation of sequence diagram 1

  1. A user or an application kicks off our main “Orchestrator Workflow”.

  2. The Orchestrator Workflow runs in a loop. In each iteration, it calls an Activity, executed by an Activity Worker.

  3. This loadData Activity interacts with the database to fetch a defined “batch” of records, often using pagination.

  4. Once a batch is received by the Orchestrator, it then, for each record in that batch, starts a Child Workflow.

  5. Each Child Workflow is a separate, independent, and durable execution that handles the specific processing for that single record.

  6. The Orchestrator maintains its internal state (like lastProcessedId) to ensure that if it fails and restarts, it knows where to resume fetching the next batch without duplication.

  7. The loop continues until no more records are found in the legacy database.

Sequence diagram of Child Workflow.

Explanation of sequence diagram 2

  1. This diagram shows a detailed view of what happens within a single Child Workflow (e.g., Payment Processing Workflow).

  2. It orchestrates a series of Activities like processing a payment or sending email communication..

  3. Each Activity interacts with an external service – here, our PaymentProcessingService and EmailService.

  4. Temporal’s built-in retry mechanisms would handle transient failures for any of these Activities, ensuring the overall policy payment or email communication processes are robust

  5. Upon completion, the Child Workflow’s status is known by the Temporal Server, which can be observed by the Orchestrator.

Key benefits of Temporal in SageSure’s modernization journey

Conclusion

Migrating our core workflows from legacy RDBMS based applications to Temporal was not just about fixing immediate problems; it was about transforming the fundamental way SageSure operates. It liberated our critical business logic from the confines of outdated architectures, allowing us to innovate faster, improve customer experience, reduce operational risk, and build systems that are ready for the demands and evolution of the modern Insurance Tech landscape.