Message Driven Architecture to DECOUPLE a Monolith

preview_player
Показать описание
Message driven doesn't need to apply just to Microservices. You can apply a Message Driven Architecture to a Monolith to decouple concerns. Consuming Commands and Events to handle concerns into their isolated units. The asynchronous and isolation will also enable your application to be more reliable and resilient.

💥 Join this channel to get access to source code & demos!

🔥 Don't have the JOIN button? Support me on Patreon!

0:00 Intro
1:29 Events & Commands
3:16 Code Sample
4:55 Publish/Subscribe
8:30 Command/Queue
Рекомендации по теме
Комментарии
Автор

I love the lack of mumbo jumbo on this channel. it gets straight to the point. Thank you, sir.

wenas
Автор

Thank you.

I've been following you for almost a year now, and almost all of the concepts have finally clicked for me.
It was really hard as I was involved in a lot of "Turd Pile" codebases that were primarily data-centric, but after shifting gears towards behavior-centric thinking and design, it makes sense now.

The Actor model is such a powerful, yet severely underrated concept in software design.

I hope you reach an even broader audience, because the software market is overflown with hot mess maestros trying to shoe-horn CRUD into every single type of problem domain.

mabdullahsari
Автор

when order is placed, another use case I was wondering about is how to handle updating inventory and quantity on-hand amounts so the shopping cart system can show items that are in stock or out of stock

osman
Автор

Great video. I've been watching a lot of your videos lately and have learnt a lot of new stuff from you. You show a really high level of overall software engineering knowledge. Really enjoying that you cover latest trends and give concrete examples, especially in the context of enterprise-level applications. I just became a developer level subscriber and encourage others to do the same 🤓

justasdautaras
Автор

please keep making great vids like this!

LifeShortBeNatty
Автор

A great video once again! I disagree that messaging _must_ be asynchronous. If you're starting with a big monolith (as I am) and working toward a CQRS architecture, you can use Paramore's Brighter to add a message broker (command processor) and send commands in-process synchronously. You still must obey the command pattern (you don't get to return updated values) but you get that first step of separation without having to code in asynchronicity from the start. Once you have turned service calls into commands then you can find those commands that are slow and send them off to the out of process queue.

Your example is great and has been good for validation, thank you!

RobLang
Автор

Great video! On top of technical benefits like retry, Pub/Sub is just such a great and simple tool to foster adhering to the Single Responsibility Principle, and it really helps adaping the mindset around it. It's the best way of the Hollywood Principle - Don't call us, we'll call you. You're done with your responsibility, and now it's up to whoever feels like working on top of it, it's not your duty to tell explicitly tell people.

allinvanguard
Автор

Excellent content! Insofar as they can be, your opinions are correct.

federatedmicroservices
Автор

Hey,
Thanks for knowledge. Do you think it's important to use third party tool like rabbitMQ to emit events ? Or for example EventEmitter in Javascript can be used to achieve the same.

freshone
Автор

If for some reason you can't use message broker and you want this same functionality you can "simulate" with a job and error table (in the case of not sending email)

JosifovGjorgi
Автор

Great video! But would you recommend to also use the outbox pattern including idempotent consumers?

Hilmer
Автор

Where does the Handle method live? Is it "just another request"? Is it a background thread like a hosted service?
If a user clicks the button, it
1) sends an http request to one endpoint
2) does work + publish a message
3) send back a response
... and then? my first request is done, where is the subscribe code being executed?

whatgoglikeno
Автор

Great video!

How would you deal with an event that has multiple subscribers and one of them fails?

If the message gets picked up from the queue again then both notification handlers would get invoked again, even though one or them already handled the message.

lukassinkus
Автор

Great video! I like the Command/Queue part. Even if all the business logic is complex and time consuming, the server can respond very quickly. The downside would be that the client would not get any meaningful response. For example the order might fail because the product is out of stock. I guess real time (websocket) connection with the client could solve the problem. Wonder if this is the best way to go because scaling websocket is also quite a challenge

sihoonkim
Автор

Are Commands also available in CAP or MassTransit ? Can you give some advice which to choose for Messaging when you can not use NServiceBus ? Btw thanks for all this information about the latest trends which are not covered much at university.

christianresdezch
Автор

Be aware that the message schema can be a (hidden) form of coupling. You may need anti-corruption layers on any consumer.

MerrionGT
Автор

Is anyone successfully applied this pattern into the monolith codebase, essencially in the write-heavy system? because when the monolith is both publisher and consumer, It has to process x2 (or even more) work load, Is It still effective?

tinpham
Автор

Sounds like you've replaced highly reliable and simple intra-process messages with less reliable and additionally complex inter-process messages. Congrats, you've got a distributed monolith. Imagine thinking installing a message bus and creating all the additional infrastructure is better than a 'sent' flag in your data source.

wg
Автор

Bad idea, unnecessary complexity. Difficult to debug or trace bugs. Simple class, method calls is sufficient and perfect in a monolith.

awmy