Feature Toggling To Support Event-Driven Architecture

Javen Seow
Government Digital Services, Singapore
3 min readFeb 9, 2024

Background

Event-Driven Architecture has been the buzzword in recent times which allows for different components in the application to communicate with one another through events. This greatly complements the implementation of Microservices where both can be used together to achieve an easily scalable and decoupled application.

This is the architecture used for my current project where our application ingests and processes claims from various medical institutions. However, there was one consideration that came to our minds while we were building it — given that there are many medical institutions involved, when either i) our own system is going through maintenance or ii) other external systems that we call performs their own maintenance or iii) there are unexpected errors faced, we want to be able to react to these activities without the need to constantly inform all users.

As such, the team implemented a feature flag to stop the ingestion of claims and any claim related documents when there is any maintenance or errors faced during any stage of claim processing that requires further investigation.

Solution

Feature Toggles (or Feature Flags) is one possible way to meet this need.

There are many ways that feature toggles can be used to support production needs. According to Martin Fowler, there are 4 broad categories that Feature Toggles can be used, namely Permissioning Toggles, Experiment Toggles, Ops Toggles and Release Toggles. This provides support to a spectrum of operational needs in very versatile ways.

For my project, we are able to meet our need through a very simple way of using the feature toggle.

In this article, I will briefly go through how my team utilised the feature toggle to meet the operational need as stated above.

Implementation

Technology Stack:

  • Unleash — Feature flag management tool
  • Gitlab
  • Spring
  • Camel

Configuration

Unleash dependency in pom.xml

This is the library that we are referencing in our code.

Application Configuration in application.yml

These information can be found in the GitLab feature flag page for the repository that the feature toggle will be implemented in.

Service

In the service that the feature toggle is implemented on, a scheduler is added to trigger every minute to check on the status of the feature toggle via Unleash. If the feature toggle is set to enabled, the SQS responsible for claim ingestion will also be enabled. Likewise, if the feature toggle is set to disabled, the SQS responsible for claim ingestion will also be disabled.

In GitLab, the feature toggle can be toggled using the UI provided.

Feature flag page in GitLab

Conclusion

The use case of the feature toggle was rather simplistic in my project and it definitely has a lot more potential to meet even more and complicated use cases that I’ll hopefully have the opportunity to try.

--

--