toonvanstrijp / nestjs-i18n

The i18n module for nestjs.
https://nestjs-i18n.com
Other
627 stars 101 forks source link

I18nContext undefined for RabbitMq messages #581

Open linconsdev opened 9 months ago

linconsdev commented 9 months ago

Describe the bug

I'm using microservices with RabbitMq and I'm trying to pass language over message in message header. I've made customer resolver and it does actually resolve the right language from header and returns it but in service i18nContext is always undefined.

I've also put { inheritAppConfig: true } in main.ts for RabbitMq

I've also noticed that in controllers i18nContext is ok but in services is undefined...

Reproduction

2 nestjs hybrid applications with rabbitmq

System Info

Win11

Used Package Manager

npm

Validations

lucas-gregoire commented 8 months ago

Hello,

On RabbitMQ consumers, HTTP middlewares aren't used, so we only rely on I18nLanguageInterceptor to resolve the lang and initialize the I18nContext, but currently it doesn't allow to define additional interceptors on endpoints/rmq consumers.

So maybe you have additional interceptors on your RabbitMQ consumers ? In this case, I think your issue could be solved by the PR i've just opened: #594.

Or maybe you have a different setup, can you tell a bit more about it ? What library do you use for your RabbitMQ subscriptions ?