我有一个 rabbitmq 服务,它有一个队列,消息中没有架构 json。
像这样:
{"customFieldOne": "foo", "another": "bar", "numbers": [3, 5, 8]}
但是带有rabbitmq的nestjs需要一个json模式,像这样:
{"pattern": "my-pattern", "data": {"fieldOne": 1 ...}}
它必须有模式和数据字段。
有没有办法在没有定义模式或模式的情况下使用任何 json 消息?
在我的代码中,我使用模式使用,但我需要使用 nestjs 微服务使用来自rabbitmq 的任何数据。
@MessagePattern('my-pattern')
// @EventPattern('my-pattern')
getNotifications(@Payload() data: number[], @Ctx() context: RmqContext) {
console.log(data);
console.log(`Pattern: ${context.getPattern()}`);
}
我该怎么做?