publishing message from redis-cli dont get recieved in nest js

Viewed 13

i did set up microservice with nestjs and Redis and i did test it from another similar one and it did work but when i want to test it using redis-cli this way

PUBLISH add "message"

or

PUBLISH update "message"

It doesn't work my microservice doesn't receive the message and my setup in nest

import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { WatchersService } from './watchers.service';

import { PostDto } from '../dto/post.dto';

@Controller()
export class WatchersController {
  constructor(private readonly watchersService: WatchersService) {}

  @MessagePattern({ cmd: 'add' })
  up(@Payload() data: PostDto) {
    return this.watchersService.up(data);
  }

  @MessagePattern({ cmd: 'update' })
  down(@Payload() data: PostDto) {
    return this.watchersService.down(data);
  }
}

and that's how I send messages from another microservice

import { Body, Controller, Inject, Post } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';

@Controller()
export class AppController {
  constructor(@Inject('RANDOM_SERVICE') private client: ClientProxy) {}

  @Post('/add')
  deviceUp(@Body() data) {
    return this.client.send({ cmd: 'add' }, data);
  }
  @Post('/update')
  deviceDown(@Body() data) {
    return this.client.send({ cmd: 'update' }, data);
  }
}

0 Answers
Related