AlariCode / nestjs-rmq

A custom library for NestJS microservice. It allows you to use RabbitMQ or AMQP.
https://purpleschool.ru
MIT License
289 stars 40 forks source link

Requested service doesn't have RMQRoute with this path #53

Closed alissonsilvajs closed 2 years ago

alissonsilvajs commented 2 years ago

Hello @AlariCode, I'm trying to connect nest.js with python, and return this error RMQError: Requested service doesn't have RMQRoute with this path

// server.ts
  async generate(id: number): Promise<any> {
    try {
      return await this.rmqService.send('generate', id, { timeout: 30000 });
    } catch (error) {
      // ...
    }
  }
// main.py
#!/usr/bin/env python3
import os
import pika as broker
import json
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

class Application:
    def __init__(self):
        self.connection = broker.BlockingConnection(
            broker.ConnectionParameters(host=os.getenv("RABBITMQ_HOST")))
        self.channel = self.connection.channel()

        self.channel.queue_declare(queue=os.getenv("RABBITMQ_QUEUE"), exclusive=False)
        self.channel.basic_consume(queue=os.getenv("RABBITMQ_QUEUE"), on_message_callback=self.callback, auto_ack=False)

        print("[DEBUG] Waiting for messages. To exit press CTRL+C")
        self.channel.start_consuming()

    def callback(self, ch, method, props, body):
        try:
            print("[DEBUG] Received")
            self.channel.basic_ack(delivery_tag = method.delivery_tag)
            self.channel.basic_publish(exchange='pdfs', routing_key=props.reply_to, body=json.dumps({'pattern': 'generate' }))
        except Exception as e:
            print(e)

if __name__ == "__main__":
    Application()
  }
AlariCode commented 2 years ago

@alissonsilvajs, hi! This error means, that Nest app got an RMQ message, but doesn't have @RMQRoute with this path to handle the request.