Giter Site home page Giter Site logo

Dead code - isTopicExists about nestjs-rmq HOT 3 CLOSED

alaricode avatar alaricode commented on August 12, 2024
Dead code - isTopicExists

from nestjs-rmq.

Comments (3)

AlariCode avatar AlariCode commented on August 12, 2024

It will be triggered in case:
You publish app with @RMQRoute('myTopic') but after some time decide to refactor your code and changed route to @RMQRoute('myNewTopic'). If any of other microservices will use old route this error will be triggered.

from nestjs-rmq.

mjarmoc avatar mjarmoc commented on August 12, 2024

Are you sure :)? If you send('myTopic', payload) I think the myNewTopic microservice will not do anything, and all others microservices will response as previously. @RMQRoute registers topics in the exchange that are used to bind to queues, so I can't imagine a scenario where the route does not exist in the controller, because if there is no route, then the message will not be delivered to queue, thus not consumed, thus not checked.

Correct me if I am wrong :)

from nestjs-rmq.

AlariCode avatar AlariCode commented on August 12, 2024

When you first connecting with myTopic, lib will do the following:

  • Check if exchange exists or create it.
  • Check if queue exists or create it.
  • ! Bind topic to a queue, so if any message with this topic come to exchange it will redirected to this queue.
  • Service starts listening to this queue.

So after service stops, topic will stay bound to queue inside rabbitmq until you unbind it manually or drop RMQ configs.
When you start with myNewTopic:

  • Exchange will exist
  • Queue will exist
  • Another binding with new topic to old queue will be created.
  • Service starts listening to this queue.

So after that we will have two bindings:

myTopic -> myQueue
myNewTopic -> myQueue

And 1 consumer that only knows how to deal with myNewTopic. But when you send myTopic it will get to the consumer because of bondings. And this code will be triggered)

from nestjs-rmq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.