Тёмный

RabbitMQ - RPC with NodeJs (request-reply pattern) 

Computerix
Подписаться 3,5 тыс.
Просмотров 8 тыс.
50% 1

We're gonna implement the RPC (remote procedure call) pattern in Nodejs, using 2 different services: RPC_Client and RPC_Server, in order to understand the concepts of request-reply in RabbitMQ while creating a real case scenario.
Useful links:
---------------------
To learn the basics of RabbitMQ : • RabbitMQ basics (Inclu...
Microservices using RabbitMQ (Message Queuing) : • NodeJs Microservices u...
Implementing a request time out mechanism : • Promise.race() to hand...
Code repo : github.com/charbelh3/RabbitMQ...
TimeStamps:
----------------------
0:00- What is RPC
0:33- Explaining how it works
2:16- 2 Problems that we need to handle
3:09- The reply_to and correlation_id properties
3:52- Where is the exchange in all this??
4:42- Getting started with the RPC_Client application
5:42- Creating the RabbitMQClient class
7:28- Adding the Initialize message to our RabbitMQClient class
12:13- Creating the Consumer class in RPC_Client
16:00- Creating the Producer class in RPC_Client
21:14- Finalizing the RabbitMQClient class
23:28- Analyzing RabbitMQ monitoring management tool
25:13- Calling the /operate API
26:40- Problem when using the rabbitMQClient in different files
28:31- Fixing the first problem
29:26- Showing the problem with using new instances
30:00- Turning the RabbitMQClient class into a Singleton
34:00- Using the RabbitMQClient as a Singleton in our app
35:34- Planning for the RPC_Server
36:09- Modifying the code in the RPC_Server application
42:28- Creating the MessageHandler in RPC_Server
49:10- Analyzing RabbitMQ monitoring management tool
50:02- Adding the headers property to messages in RPC_Client
51:42- Consuming the RPC_Server response correctly
52:30- How to match the responses to their requests?
53:20- Adding the Event Emitter and emitting new messages from the Consumer
55:11- Subscribing to the event inside the Producer
56:48- Testing the events emitted by the consumer and received by the producer
57:41- How to return the response value that was emitted?
58:46- Wrapping the event with a Promise() to return the response value correctly
1:00:10- Explaining that you can produce errors as well from your RPC_Server and handle them in your RPC_Client
1:00:56- Message expiration time and request timeout

Опубликовано:

 

28 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 31   
@basemmostafa3307
@basemmostafa3307 Год назад
This is RU-vid's hidden treasure that's just waiting to be found! In-depth RabbitMQ content is very scarce on RU-vid, and message brokers in general, and you did a signifacnt job on explaining it. Impressive work and effort, bro! Can't wait for this to blow up.
@Computerix
@Computerix Год назад
Thank you for the lovely comment !
@theunfilteredcomment5656
@theunfilteredcomment5656 Год назад
I can see your channel growing quickly. You're giving the people what they need 👍💪
@t-distributedkid3825
@t-distributedkid3825 8 месяцев назад
I couldnt find one proper video explaining RPC with node... Finally found this
@Computerix
@Computerix 8 месяцев назад
I'm glad my video helped !
@BilalKhan-sx9eu
@BilalKhan-sx9eu 10 месяцев назад
Best explanation so far
@ShubhamSharma717
@ShubhamSharma717 2 месяца назад
Thanks for the tutorial you saved my a$$
@farzadforuozanfar5786
@farzadforuozanfar5786 Год назад
Thank you for this very good and professional course that is available for free
@hassanmhassan5500
@hassanmhassan5500 Год назад
Amazing bro, thank you for sharing such precious knowledge
@Computerix
@Computerix Год назад
You're welcome ! Glad you enjoyed the video.
@NOName-ge8iu
@NOName-ge8iu 9 месяцев назад
such nice man you are , such nice tutorial
@juliusngwu
@juliusngwu 9 месяцев назад
Good job. Thanks
@LawZist
@LawZist 11 месяцев назад
Subscribed :), one thing you can add is to remove the event listener from once the response came back
@Computerix
@Computerix 11 месяцев назад
Thank you! Great suggestion
@anonymoususer1087
@anonymoususer1087 Год назад
Your content is truly invaluable! If you have the time, would it be possible for you to create a video or series on building a mini ecommerce or social media backed application using multiple services, such as authentication, user management, order management, product management, and cart management, while adhering to best practices? This would greatly benefit learners looking to expand their knowledge in this area.☺
@Computerix
@Computerix Год назад
Thanks for the feedback! I'm glad the video was helpful. And great idea, will make sure to add it to the video ideas list :)
@andrewananenko797
@andrewananenko797 3 месяца назад
Great video man! I would want to know how you did this magic on 19:31? (check available props of object) - which is hotkey for that? I'm looking forward new videos about RabbitMQ ! Thanks
@Computerix
@Computerix 3 месяца назад
Ctrl + space (Windows) cmd + I (Mac, I believe?) Thanks for the feedback!
@user-ws3zi4vg5p
@user-ws3zi4vg5p 5 месяцев назад
Thank you for the Tutorial, may I ask why we created two channels each for a producer and a consumer, Can't we connect both producer and consumer to a single channel on the client side and similarly connect producer consumer to only one channel on server side, so in total we have two channels on RabbitMQ?
@Computerix
@Computerix 5 месяцев назад
I'm glad you enjoyed! It is recommended to use different channels when producing / consuming for performance reasons and to avoid issues. (www.cloudamqp.com/blog/the-relationship-between-connections-and-channels-in-rabbitmq.html check the last 2 points)
@bikramgyawali7292
@bikramgyawali7292 Год назад
this is really awesome content about RabbitMQ ever seen . I got good knowledge from this and your other video about rabbitmq , Can you provide me the source code link ? Thankyou again
@Computerix
@Computerix Год назад
Thank you so much for the feedback! Here is the repo : github.com/charbelh3/RabbitMQ-RPC-Example
@bikramgyawali7292
@bikramgyawali7292 Год назад
@@Computerix thankyou for providing the source code .
@user-kg2gv2bl6d
@user-kg2gv2bl6d 11 месяцев назад
How to manage rollback mechanism.? for example if my 1st service have update some data after update completed based on 2nd service add some data, if 2nd service failed i want to rollback 1st service execution, how i can achive multiple micro-service in nodejs.?
@Computerix
@Computerix 11 месяцев назад
Before updating the data, you can wait for the second service to complete its task successfully. So using await, you wait for the second service to return a success response (and a potential result), and once this is returned, you update the data in the first, if an error occurs or the results aren't returned, you throw an error in the first service (or do some other task) instead of updating the data that depends on the outcome of the second service
@user-kg2gv2bl6d
@user-kg2gv2bl6d 11 месяцев назад
okay thankyou for your answer.!@@Computerix
@user-kg2gv2bl6d
@user-kg2gv2bl6d Год назад
can i use same request-replay-pattern with kafka.? can you please create video about request-replay-patter with kafka in nodejs with typescript.?
@Computerix
@Computerix Год назад
Yes, this can be done in kafka as well. I will add the idea to my list, thank you
@wymvlogs
@wymvlogs 7 месяцев назад
how can i connect to you 👋
@hoangofficial8021
@hoangofficial8021 Год назад
hi, what if a service acts as both a client and server?
@Computerix
@Computerix Год назад
Hello! In that case, both of them also play the role of a consumer and a producer (just like in this scenario), but you would need a reply queue for each of the two, and you would need to consume messages from 2 different queues in each of the 2 different services (so each service would have a reply queue, to get the response from the other service, and another queue to receive messages , to get the request from the other service(s))
Далее
NestJs Microservices with RabbitMQ
23:21
Просмотров 9 тыс.
I tried 8 different Postgres ORMs
9:46
Просмотров 396 тыс.
Лепим из пластилина🐍
00:59
Просмотров 549 тыс.
Good APIs Vs Bad APIs: 7 Tips for API Design
5:48
Просмотров 223 тыс.
The End Of Jr Engineers
30:58
Просмотров 402 тыс.
What is a MESSAGE QUEUE and Where is it used?
9:59
Просмотров 956 тыс.
Generics: The most intimidating TypeScript feature
18:19
When RESTful architecture isn't enough...
21:02
Просмотров 257 тыс.