Reputation: 33
I am building a nestjs app where I want to create a rabbitmq
@Module({
imports: [
ClientsModule.register([
{
name: 'rabbitmq',
transport: Transport.RMQ,
options: {
urls: [
'amqp://guest:guest@rabbitmq',
],
queue: 'my_queue',
},
},
]),
],
controllers: [],
providers: [RabbitMQService],
exports: [RabbitMQService],
})
And service:
@Injectable()
export class RabbitMQService { constructor( @Inject('rabbitmq') private client: ClientProxy ) {} }
The error I am getting is: Nest can't resolve dependencies of the RabbitMQService (?). Please make sure that the argument rabbitmq at index [0] is available in the RabbitMQService context. As much I am aware, this should work, but nope. Could anyone help?
Upvotes: 1
Views: 1404
Reputation: 70131
From the error, it looks like somewhere in your application you have RabbitMQService
in an imports
array where @Module()
classes are supposed to go. Make sure that you keep providers
and other @Injectables()
to the providers
array and keep @Module()
and other DynamicModule
s to the imports
array. Common error docs
Upvotes: 3