In a Spring Cloud microservices environment, we are experiencing inconsistent internationalization (i18n) message resolution across services and request contexts.
Specifically:
MessageSource.getMessage(...) works correctly in:
- Controllers
- Standard HTTP request threads
- But fails or returns default messages in:
- Async tasks (
@Async)
- Reactive contexts (WebFlux)
- Feign client fallback / error decoder
- Global exception handlers
- Scheduled jobs
The resolved locale is sometimes:
null
- Always
Locale.getDefault()
- Or different from the request's
Accept-Language header
Expected Behavior
- Locale should be resolved consistently based on:
Accept-Language header (for HTTP requests)
- Explicitly set
LocaleContext
- i18n messages should work uniformly in:
- Controllers
- Exception handlers
- Async tasks
- Reactive pipelines
- Feign-related components
In a Spring Cloud microservices environment, we are experiencing inconsistent internationalization (i18n) message resolution across services and request contexts.
Specifically:
MessageSource.getMessage(...)works correctly in:@Async)The resolved locale is sometimes:
nullLocale.getDefault()Accept-LanguageheaderExpected Behavior
Accept-Languageheader (for HTTP requests)LocaleContext