Lesson 137 - Rest vs. Messaging

preview_player
Показать описание
Developers and architects are often faced with the age-old question: Should I use REST or messaging for my communication protocol? More appropriately, this question becomes more about whether to use synchronous or asynchronous communication. In this lesson Mark Richards discusses some of the trade-offs and implications of each of these communication styles to help you decide which one is most appropriate for your situation.

Reference Links:

Рекомендации по теме
Комментарии
Автор

Great video as always! Up to the Mark :)

farrukhijaz
Автор

Thanks for the nice video.

As always, it depends on tradeoffs you want/need to choose for whatever use-case that needs to be supported.

Regarding wishlist/catalogue example, and given we’re ok with eventual consistency, I would consider storing all necessary data needed for it to function as needed in a db belonging to the wishlist. That part should of course be more of read-mode, as catalogue is considered to be “master”-data in this case. Anytime a product in catalogue would update, I would make sure that ProductUpdated event ends up as a message on a bus, and then wishlist (and whoever else needed) could pick it up and update its data accordingly.
Maybe that is what you’re also trying to explain in your east-west communication analogy? I do see by the graphics, that both have their own dbs/tables.

stjepankarin
Автор

In your last example with Wishlist and Catalog, wouldn't the request to the Catalog be synchronous? Surely Wishlist service has to block until the response has been received. So I'm not really sure what "messaging" provides in this context. Couldn't the Private API be REST as well? Or is the overall argument that it's easier and quicker to implement and maintain a private api over messaging?

matthiashjalmarsson
Автор

Could you give feedback if this would instead be a more valid solution?

The Product service can broadcasts the added/updated product payload to the message queue everytime a PUT/POST call is made to it. The wishlist service listening to this will persist the description field that it needs from that payload and will never have a request-time dependency on the product service being available?

Curious to know if there's a drawback to this approach?

manocharishab
Автор

Wait, how does messaging creatre "private api"? And how does this "private api" created by messaging know which fields to message back to Whishlist Service?

HiOctaneVideoShare
Автор

Interesting, an introduction to what you mean by asynchronous and synchronous would have been nice though. It seems that in the context of this video they are very different from what they are in a programming (let's say Promises in JS or async in python)

razean
Автор

Thanks again for a great video. Of course it depends, but would you normally use rest between an orchistrator service and the downstream services, due to the north/south "rule"?

berntrune