AI Briefing
KO

Kakao My Subscription Develops Zero-Downtime DTO Migration Module to Unify API Cases

·2024.11.19 00:00

Key point

Utilized RequestBodyAdvice and Jackson Custom Deserializer to unify the case of 900 DTOs to Camel without server downtime.

1 / 4

Details

The Kakao My Subscription service performed a zero-downtime migration to unify mixed DTO naming conventions (Camel, Snake, etc.) to Camel case during backend development. The existing gradual change approach caused case mismatches between the gateway and business logic servers, parsing errors for nested DTOs, and complex dependency management issues during zero-downtime deployments.

Request Processing: Leveraging Spring RequestBodyAdvice

Applied Spring's RequestBodyAdvice, which operates just before Request data parsing. Since Filters or Interceptors made it difficult to identify target classes or modify the original Body, Java Reflection was used in the beforeBodyRead method to check annotations on the target class (@JsonNamingStrategy, @JsonProperty, etc.) and convert the case. For Generic types, parsing was based on the innermost class, while Map types were excluded.

Response Processing: Applying Jackson Custom Deserializer

Due to the characteristic of ResponseBodyAdvice operating after data delivery rather than before, Jackson's Custom Deserializer was used. JsonDeserializer and ContextualDeserializer were implemented for the ApiResponse Wrapper class to secure Generic type information at the point of deserialization, converting the case with the same logic as Request.

Resolving Concurrency Issues and Results

In the initial implementation, Jackson's caching mechanism prevented createContextual from returning a new Deserializer instance, causing a concurrency issue where multiple sessions shared the same instance and type information became mixed. To resolve this, createContextual was modified to always return a new instance. Finally, by applying these modules, the case of over 900 DTOs was successfully changed without server downtime.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.