Stephin varghese
Stephin varghese

Reputation: 1

RabbitMq with nestjs

I want to implement a pub/sub model in nestJs using rabbitMQ. I used the topic exchange for this all the configration is fine. because when i run the system it create exchang queue and routing key but the issue is it not consume the message This is my controller file

import { Controller, Logger } from '@nestjs/common';
import {
  Ctx,
  EventPattern,
  MessagePattern,
  Payload,
  RmqContext,
} from '@nestjs/microservices';

@Controller()
export class RabbitMQController {
  private readonly logger = new Logger(RabbitMQController.name);

  @EventPattern('pingServerDataSync.data')
  async handlePingServerData(@Payload() data: any, @Ctx() context: RmqContext) {
    this.logger.log(
      `Received pingServerDataSync.data message: ${JSON.stringify(data)}`,
    );

    // Your business logic here

    // Acknowledge the message
    const channel = context.getChannelRef();
    const originalMsg = context.getMessage();
    channel.ack(originalMsg);
  }
}

When i consume manually it hit and return the the data. but not in controller and every time i got one warning WARN [Server] An unsupported event was received. It has been negative acknowledged, so it will not be re-delivered. Pattern: undefined

Upvotes: 0

Views: 21

Answers (0)

Related Questions