-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: channel is not available #423
Comments
Can you please share an example repo that demonstrates the issue so that it can be properly investigated? |
@WonderPanda here is the repo link https://github.com/singhajit1616/backend_nest_api |
Where is the value for |
@WonderPanda getting these values from .env file. And have updated the repo. And I have noticed that
And the log is also showing the same config under the package
But while accessing the connection through
|
Hello, I have similar trouble. This is my module@Module({
imports: [
RabbitMQModule.forRootAsync(RabbitMQModule, {
useFactory: createRabbitMqConfig,
inject: [ConfigService],
}),
],
providers: [RabbitMqService],
exports: [RabbitMqService],
})
export class RabbitModule {} This is an config file that export an function with configuration fileimport { RabbitMQConfig } from '@golevelup/nestjs-rabbitmq';
import { ConfigService } from '@nestjs/config';
export const createRabbitMqConfig = (configService: ConfigService) => {
const config: RabbitMQConfig = {
exchanges: [
{
name: 'amq.direct',
type: 'direct',
},
],
channels: {
'channel-1': {
default: true,
},
},
uri: configService.get<string>('RABBITMQ_CONNECTION_URL'),
enableControllerDiscovery: true,
connectionInitOptions: { wait: true },
};
return config;
}; This is my service fileimport { AmqpConnection, RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
@Injectable()
export class RabbitMqService implements OnModuleInit, OnModuleDestroy {
constructor(private readonly amqpConnection: AmqpConnection) {}
@RabbitSubscribe({
exchange: 'amq.direct',
routingKey: 'messages',
queue: 'messages',
queueOptions: {
channel: 'channel-1',
},
})
message(message) {
console.log(message);
}
async publishMessage(message) {
await this.amqpConnection.publish('amq.direct', 'messages', message);
}
onModuleDestroy() {
console.log('RabbitMqService destroyed');
}
async onModuleInit() {
console.log('RabbitMqService initialized');
}
} The basic problem is that the "amqpConnection" is not injected on service and due this is undefined |
I think this is bug of the version 2.3.0 |
I can attest downgrading to 2.2.0 works. |
@singhajit1616 @nitoba @fmalk Try specifying |
Since we're still using 2.2 for our backend, best if we tried to update it to current version and see if problem persist. However that's not a priority. |
Also getting this in the latest ( |
I'm creating an API which will accept the message and then will publish it to the queue.
So i have initialized my app.module.ts
And in the service imported the library AMQPService like this
constructor(private readonly amqpConnection: AmqpConnection){}
So when, using the methods exposed like this
this.amqpConnection.channel.assertExchange(exchange.name, exchange.type, exchange.options);
and it throwsError: channel is not available.
When logged amqpConnection, recieved this object
Expectations:
The text was updated successfully, but these errors were encountered: