Open
Description
Hello nestjs/amqp community,
I would like to integrate this library to my project, but I am having a problem to run example from documentation.
ERROR:
Nest can't resolve dependencies of the CrawlerService (?, AMQP_CONNECTION_PROVIDER_0). Please make sure that the argument AMQP_CONNECTION_PROVIDER_test at index [0] is available in the CrawlerModule context.
Potential solutions:
- If AMQP_CONNECTION_PROVIDER_test is a provider, is it part of the current CrawlerModule?
- If AMQP_CONNECTION_PROVIDER_test is exported from a separate @Module, is that module imported within CrawlerModule?
@Module({
imports: [ /* the Module containing AMQP_CONNECTION_PROVIDER_test */ ]
})
My app.moule.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ENV_DB } from 'const/env';
import { BucketModule } from 'modules/core/bucket/bucket.module';
import { CrawlerModule } from 'modules/core/crawler/crawler.module';
import { ItemsModule } from 'modules/items/items.module';
import { ProvidersModule } from 'modules/providers/providers.module';
import { UsersModule } from 'modules/users/users.module';
import { AmqpModule } from 'nestjs-amqp';
@Module({
imports: [
AmqpModule.forRoot({
username: 'xxxxx',
password: 'xxxxxx',
hostname: 'xxxxxx',
port: 5672,
protocol: 'amqp',
name: 'test',
}),
],
})
export class AppModule { }
My crawler.module.ts
@Module({
imports: [
AmqpModule.forFeature(),
],
providers: [
CrawlerService,
],
exports: [CrawlerService],
})
export class CrawlerModule { }
My crawler.service.ts
@Injectable()
export class CrawlerService {
constructor(
@InjectAmqpConnection()
private readonly amqp: Connection,
) { }
async test(message: string) {
await this.amqp.createChannel((err, channel) => {
if (err != null) {
Logger.alert(err, 'TestProvider');
}
channel.assertQueue('test_queue_name');
channel.sendToQueue('test_queue_name', message);
});
}
public async process() {
await this.test('test')
}
}
What is wrong? Looks like I have all steps from example.
Thank you for any help.
Metadata
Metadata
Assignees
Labels
No labels