#An unsupported event was received. It has been acknowledged, so it will not be re-delivered

19 messages · Page 1 of 1 (latest)

primal wave
#

Hello, i got stuck with the receiver can't handle the event in micro-service with RabbitMQ RMQ.
I tried to used send & subscribe & emit and EventPattern & MessagePattern but it's always got the same error

[Nest] WARN [Server] An unsupported event was received. It has been acknowledged, so it will not be re-delivered. Pattern: notifications

Minimum reproduction code
https://github.com/PacoPacoPakitor/microservice-rmq

Steps to reproduce

  1. nest start --watch
  2. nest start billing --watch
  3. use postman to send this request:
    http://localhost:3000/orders?name=hha&price=123213&phoneNumber=123213
  4. you will be able to see the logs from orders service :
    Calling createOrder request: { name: 'hhhhhaaaa', price: 213, phoneNumber: 213 }
  5. but no log from the billing service
GitHub

Contribute to PacoPacoPakitor/microservice-rmq development by creating an account on GitHub.

primal wave
#

I provide my main codes here, hope they can help you to help to locate the issue, thanks!

RmqModule:

  name: string
}

@Module({
  providers: [RmqService],
  exports: [RmqService],
})
export class RmqModule {
  static register({ name }: RmqModuleOptions): DynamicModule {
    return {
      module: RmqModule,
      imports: [
        ClientsModule.registerAsync([
          {
            name,
            useFactory: (configService: ConfigService) => ({
              transport: Transport.RMQ,
              options: {
                urls: ['amqp://rabbitmq:5672'],
                queue: configService.get<string>(`RABBIT_MQ_${name}_QUEUE`),
              },
            }),
            inject: [ConfigService],
          },
        ]),
      ],
      exports: [ClientsModule],
    }
  }
}

RmqService:

export class RmqService {
  constructor(private readonly configService: ConfigService) {}

  getOptions(queue: string, noAck = false): RmqOptions {
    return {
      transport: Transport.RMQ,
      options: {
        urls: ['amqp://rabbitmq:5672'],
        queue: this.configService.get<string>(`RABBIT_MQ_${queue}_QUEUE`),
        noAck,
        persistent: true,
      },
    }
  }

  ack(context: RmqContext) {
    const channel = context.getChannelRef()
    const originalMessage = context.getMessage()
    channel.ack(originalMessage)
  }
}
#

Sender:

  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: './apps/orders/.env',
    }),
    RmqModule.register({
      name: BILLING_SERVICE,
    }),
  ],
  controllers: [OrdersController],
  providers: [OrdersService],
})
export class OrdersService {
  constructor(@Inject(BILLING_SERVICE) private billingClient: ClientProxy) {}

  async createOrder(request: CreateOrderRequest) {
    console.log('Calling createOrder request:', request)
    this.billingClient.emit('order_created', {
      request,
    })
  }
}

Receiver:

  const app = await NestFactory.create(BillingModule)
  const rmqService = app.get<RmqService>(RmqService)
  app.connectMicroservice(rmqService.getOptions('BILLING'))
  await app.startAllMicroservices()
}
export class BillingController {
  constructor(
    private readonly billingService: BillingService,
    private readonly rmqService: RmqService
  ) {}

  @Get()
  getHello(): string {
    return this.billingService.getHello()
  }

  @EventPattern('order_created')
  async handleOrderCreated(@Payload() data: any, @Ctx() context: RmqContext) {
    console.log('-->>>>>> Receive event  data:', data)
    this.billingService.bill(data)
    this.rmqService.ack(context)
  }
}
bold cargoBOT
#

Suggestion for @primal wave:
Please format your question or answer with Markdown formatting.
It leads to better readability and an easier time to spot problems.
For code blocks, you can wrap your block with three back ticks before and after the block, and after the first three back ticks you can add a language (like ts) to add syntax highlighting.
e.g.

```ts
@Injectable()
export class MySuperAwesomeService {
constructor(@Inject('InjectionToken') private readonly dep: SomeDependency) {}

getRandomNumber(): number {
return Math.round(Math.random() * 1000);
}
}
```

Becomes :point_down:

@Injectable()
export class MySuperAwesomeService {
  constructor(@Inject('InjectionToken') private readonly dep: SomeDependency) {}

  getRandomNumber(): number {
    return Math.round(Math.random() * 1000);
  }
}
primal wave
#

An unsupported event was received. It has been acknowledged, so it will not be re-delivered

#

Hi @sudden ivy, sorry to bother you. But I saw your answers to another question that related to my issue, so could you please help with it? Thank you a lot!

bold cargoBOT
#

Please do not tag the moderators unless someone is breaking server rules.
The mods are here to help enforce the rules of the server, and while most of them are knowledgeable about Nest, they are not the only ones able to solve your question.

mellow agate
rugged pecan
#

was this issue solved, facing the same !