NodeJs Microservices using RabbitMQ (Message Queueing)

Поделиться
HTML-код
  • Опубликовано: 11 ноя 2024

Комментарии • 68

  • @AashKothari-v5d
    @AashKothari-v5d 4 месяца назад +2

    Nothing extra just pure lessons.. superb trainer..

    • @Computerix
      @Computerix  4 месяца назад

      Thank you for your comment !

  • @somasundaramp1307
    @somasundaramp1307 2 года назад +3

    Watched both RabbitMQ videos back to back. Thanks. 🐰

  • @caiocutrim3596
    @caiocutrim3596 9 месяцев назад +1

    Wow, nice video! I get an task to implement both consumer and subscriber, that helped me a lot to understand the library and I did some unit tests here.

    • @Computerix
      @Computerix  9 месяцев назад

      I'm glad it was useful to you!

  • @markohy9samy565
    @markohy9samy565 2 месяца назад +1

    Really amazing tutorial

    • @Computerix
      @Computerix  2 месяца назад

      @@markohy9samy565 thank you !

  • @DmitrySafarov
    @DmitrySafarov 8 месяцев назад

    Great explanation! Thanks!

  • @balu121000
    @balu121000 6 месяцев назад

    M late to see this video but it's very well explained.👏

  • @mahendranath2504
    @mahendranath2504 11 месяцев назад

    Thank you so much 👍🙏👋👌👏🏻🤝🫶🏻✌️🫡😎

  • @waleedjubeh5955
    @waleedjubeh5955 Год назад +1

    Thank you very much, so clear

  • @haseebahmed5065
    @haseebahmed5065 2 года назад +3

    Great explaination.

  • @kriskolev5996
    @kriskolev5996 Год назад +2

    Great tutorial! Nice and simple!

  • @aksgaming...
    @aksgaming... Год назад +1

    Nice one and great tutorial

  • @ramazanaltuntepe8857
    @ramazanaltuntepe8857 Год назад +1

    my lord thank you!

  • @fasoolya
    @fasoolya Год назад +1

    very good teacher, thank you @Computerix, is there any chance to create a tutorial where the consumer is in a browser web application? like a log viewer web page for live monitoring?

    • @Computerix
      @Computerix  Год назад

      Thank you for the suggestion!

  • @rohanpawar2301
    @rohanpawar2301 5 месяцев назад

    great tutorial

  • @user-wt2gl4xh8c
    @user-wt2gl4xh8c 6 месяцев назад

    Thank you for video. Is it possible to use nitro.js instead of express.js

  • @folksfenmin
    @folksfenmin 7 месяцев назад

    thank sir... , helpfull👍

  • @NoorulAmin-j9f
    @NoorulAmin-j9f Год назад

    very well explained, Thanks

  • @parthpawar7837
    @parthpawar7837 2 года назад +2

    How does the consumeMessages() in infoMS log all the published messages, despite calling consumeMessages() function only once in app.js ? Does calling this function once force app.js to keep listening to queue?

    • @Computerix
      @Computerix  2 года назад +2

      channel.consume() keeps on listening to the queue to consume new messages. It's like when you use app.listen() in your server to keep on listening to incoming requests on your server :)

    • @parthpawar7837
      @parthpawar7837 2 года назад +2

      @@Computerix That was super helpful, thank you! Your videos have been really helpful to me

    • @Computerix
      @Computerix  2 года назад +2

      @@parthpawar7837 I'm very glad to hear that! Thanks for your feedback

  • @ikhlasoyelami8383
    @ikhlasoyelami8383 Год назад

    This is superb

  • @farzadforuozanfar5786
    @farzadforuozanfar5786 Год назад

    thsnks its perfect course

  • @jeetchheda3675
    @jeetchheda3675 Год назад

    I want to know whether we should acknowledge the message consumed by us before processing the message or after all the processing is done ??

    • @Computerix
      @Computerix  Год назад

      It depends on your use case. If you need the message to be removed from the queue AFTER all the processing is done and not miss any potential steps, then you should acknowledge the message after finishing all the processing you require. That way, if an error occurs during processing, you do not lose the message, since it will be requeued since it wouldn't be acknowledged up until the processing succeeds..

  • @rockygamingyt2982
    @rockygamingyt2982 2 года назад +1

    Hey i need your help in this when i am starting the server 15:35 in my pc its showing cannot
    const Producer=new Producer();
    ^
    ReferenceError: Cannot access 'Producer' before initialization

    • @Computerix
      @Computerix  2 года назад +2

      Hello, make sure to import the variable as "Producer" (Capital P), and then the new variable (which is used as a class instance) should be different from that one, which is why I used "producer" with a lower "p". Point is, they should be different names :)
      Hope this helps !

  • @muhammedashkar692
    @muhammedashkar692 3 месяца назад

    should i download the rabbitmq exe for windows or run a docker container?

    • @Computerix
      @Computerix  3 месяца назад

      @@muhammedashkar692 Either would work ! Up to you

    • @muhammedashkar692
      @muhammedashkar692 3 месяца назад

      @@Computerix thanks.

  • @PareshPandit-s6k
    @PareshPandit-s6k Год назад

    but when I change in key it still consume the message

  • @ehSamurai3483
    @ehSamurai3483 9 месяцев назад

    Do we need exchange? I think only queue would do.

    • @Computerix
      @Computerix  9 месяцев назад +1

      There is always an exchange when sending messages, even when you use channel.sendToQueue(queueName, data) instead of channel.publish(exhangeName, key, data). The difference is when using sendToQueue, you're using the default exchange which is of type direct, and the queueName would be used as key name. In this example, since the exchange we're using is of type direct, you could use sendToQueue directly. I've made a video that uses what you've mentioned: ruclips.net/video/APfWkfkjRj8/видео.html

  • @Computerix
    @Computerix  Год назад

    RPC model in RabbitMQ (request-reply pattern) : ruclips.net/video/APfWkfkjRj8/видео.html

  • @xfaraonx1
    @xfaraonx1 Год назад

    Excelent! !

  • @frederickdarko2644
    @frederickdarko2644 2 года назад +3

    Niece Video
    God bless you
    Can we have the source code

    • @Computerix
      @Computerix  2 года назад +1

      Thanks for the feedback !
      Here you go : github.com/charbelh3/RabbitMQ-Logger-Example

  • @bernardusyoga5936
    @bernardusyoga5936 Год назад

    Hello this is a great tutorial, but i have a question, you create a async function called consumeMessages(). but why you didn't use await when calling the function? thank you

    • @Computerix
      @Computerix  Год назад

      Hello ! Normally when you have an async function and call it with await, it means you're waiting for it to complete by blocking the execution of the rest of the program. In this case, we don't care about blocking / waiting for a specific response before excuting the next lines :)

    • @bernardusyoga5936
      @bernardusyoga5936 Год назад +1

      @@Computerix hooo I get itt. Thank youu for your responsee. Really appreciate that! 👍

    • @Computerix
      @Computerix  Год назад

      @bernardusyoga5936 you're welcome! Further more, in the case of this video, we're calling the consumeMessages() function from the global scope, which means that we can't use await either way (since we're in the global scope)

  • @surajghodke1033
    @surajghodke1033 Год назад

    How to clear message/ channel once its delivered successfully

    • @jeetchheda3675
      @jeetchheda3675 Год назад

      26:07 if the message is consumed, the consumer service must call the ack() function to acknowledge the message and clear from the queue/channel.

    • @Computerix
      @Computerix  Год назад

      Sorry for the late reply. We used channel.ack(msg) in the code after consuming the message, in order to inform RabbitMQ that the message has been successfully processed and can be removed from the queue (that way it would not be requeued and consumed more than once)

  • @japan9169
    @japan9169 Год назад

    Hello bro.
    thanks for the video.
    I do have some questions regarding the channels.
    I want to create a simple chat application using RabbitMq, does that mean that for every user on the app, there will be a new channel?

    • @Computerix
      @Computerix  Год назад +1

      Hello! You can either make 1 channel and then handle the routing of the messages using the direct exchange (you can use the username or userID as a unique key for example) and then you create a queue for every new user that joins the chat app with the username/userId as a binding key
      or you can create a separate channel for every user (but that would cause performance issues if you have many users)
      So it would be better to stick to the first option

    • @japan9169
      @japan9169 Год назад

      @@Computerix ​ Thanks a lot for the quick reply.
      I will go ahead to implement the first option.
      However, I do have another question.
      Can you also explain how I can possibly implement a group chat?
      What I have in mind is a scenario whereby, a group created by a user will have a unique queue name which will serve as an identifier and the moment a user joins a group, he will begin to listen to that queue. I will also ensure that all these queues are all on the same channel.

    • @Computerix
      @Computerix  Год назад +1

      ​@@japan9169 Before answering, I wanna note that my previous answer assumes that you can only use RabbitMQ to create a chat app. In a real world application, it would be much better to use web sockets (sockets.io for example) for chat apps, instead of a message broker. So if the app you're making is for production, it would be better to either use Web Sockets, or a mix of RabbitMQ with sockets.io
      In that case, you could make 1 queue only for the whole chatting system (e.g : messaging-queue), and the message payload would contain the userID or groupID. Whenever the consumer receives a new message, it looks at the userID / groupID and you could emit a message to that ID. The client would be listening for new messages (using socket.on('new message', (payload)=>{ // code }) for example...)
      However, if you're only using rabbitMQ for your chat app for practicing reasons, then you should continue using the way proposed earlier (1 queue per user, although keep in mind, queues have metadata, so having 50k users would mean 50k queues, each having their own metadata even if they are idle..)
      Regarding your question about the group chats (and assuming you're not using the Web Sockets options). Using 1 queue per group is NOT the right way to do it, since rabbitMQ uses the round robin algorithm, meaning when a queue has multiple consumers, it would send the message to the consumers in a round robin fashion (not all users in the group chat would receive the message, BUT only 1).. So, a way to achieve what you need, would be using an exchange of type FANOUT (meaning it broadcasts the messages it receives to ALL connected queues), so you would need to create a different exchange for different group chats, and then bind a new queue for every new user that joins the group chat(you can reuse the previous created user queues)

    • @japan9169
      @japan9169 Год назад

      ​@@Computerix Yh that is absolutely correct, I want to use RabbitMq for the chat app for learning purposes.
      It seems like RabbitMq will not be the best match for creating a group.
      I will simply create a basic chat application where two people can communicate using rabbitMq

    • @Computerix
      @Computerix  Год назад

      @@japan9169 good luck !

  • @ehSamurai3483
    @ehSamurai3483 9 месяцев назад

    Isn't that same as socket io?

    • @Computerix
      @Computerix  9 месяцев назад

      They are different. RabbitMQ is a message broker that allows complex message routing based on different options (exhange type/routing keys) and you have the capability to control the message durability, message routing and message acknowledgement (delivery guarentee).
      Socket.io is an event-driven library for real-time web applications, meaning it helps implement real-time communication solutions in applications, and does not provide message queuing or delivery guarentees.
      For example, if you need to show live updates on a browser you would use socket.io. If you need to process jobs and in a controlled manner, you would use a message broker (in our case rabbitmq)

    • @ehSamurai3483
      @ehSamurai3483 9 месяцев назад

      @@Computerix Thanks for the replay but I think socket io has acknowledgement system too.

    • @Computerix
      @Computerix  9 месяцев назад

      @@ehSamurai3483I wasn't aware of that. But the main difference between socket.io and rabbitMQ is the use case. Socket.io is used in real-time web application. RabbitMQ is used as a message broker and you have more control over what happens and how jobs are processed, divided etc.. Hope his helps :)

    • @ehSamurai3483
      @ehSamurai3483 9 месяцев назад +1

      @@Computerix Thanks again, I will research on my own too.

  • @Vasim_Khan
    @Vasim_Khan Год назад

    TypeError: Producer is not a constructor ,getting this err
    when i'm starting the server

    • @Computerix
      @Computerix  Год назад

      You probably made a small mistake, feel free to check the code: github.com/charbelh3/RabbitMQ-Logger

  • @nokzeo2777
    @nokzeo2777 2 года назад

    Nice one

  • @akshaypai3528
    @akshaypai3528 Год назад

    Requesting your help :
    I followed along the video up to 16:41
    On visiting local host 3000 I get Cannot GET / before using postman.
    during the process of sending POST request in postman to the local host my program fails and I get this Error
    node:internal/process/promises:288
    triggerUncaughtException(err, true /* fromPromise */);
    ^
    Error: connect ECONNREFUSED ::1:5672
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1487:16) {
    errno: -61,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '::1',
    port: 5672
    }

    • @Computerix
      @Computerix  Год назад

      it seems you are unable to connect your app with the rabbitMQ server, can you try opening "localhost:15672/" on the browser ? It should open up the rabbitMQ management tool. If it doesn't, there is a chance you didn't install rabbitMQ correctly
      Make sure rabbitMQ is installed correctly on your machine www.rabbitmq.com/download.html

    • @AdityaChauhan-vl5lq
      @AdityaChauhan-vl5lq 7 месяцев назад

      @@Computerix Hi, installed rabbitmq, I am able to open localhost:15672/ but still having the same error as mentioned above when hitting api from postman. Kindly help in resolving this issue!