Service Oriented Architecture: Commands & Events Explained!

preview_player
Показать описание
They're both types of messages but what's the difference between Commands & Events? When should you use a command and when should use an event? I cover these questions and a hot take on if commands should fail.

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

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

0:00 Intro
0:47 Commands & Events
1:23 Consumers
3:12 Choreography & Orchestration
5:37 Can Commands Fail?

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

I’m sending to a queue for my request reply flows but my other commands are sent to a topic then I’m using filters to deliver the command via subject /label to the actual subscription which is linked to my code. I feel this way I can have an extra layer to flexibility and saves me coding queue names into anywhere. I have a topic per micro service domain and several subscriptions, all with their own filters. Happy to get comments on this.

coderider
Автор

I enjoyed this video. Some of your latter points really emphasize that it is important for us as developers to put on our business hat. Being strategic and tactical is very much a learned skill.

coderanger
Автор

Nice - awesome example at the end about concurrency issues and what to do. Just being aware of those kinds of issues is a huge thing.

jameshickey
Автор

So glad I found this channel, tons of good stuff on EDA. Subbed!

Hydrophish
Автор

I think the business understanding brought up by the question of commands failing is one of the hallmarks of being a senior developer. Understanding the Business Analyst role and how to work with it as a developer becomes uniquely important the closer you are to decision making. In some cases you have a BA you are working with and these question need to be raised and researched. In other cases, you as the developer are having to fulfill the BA role also and you need to be even more aware of such areas. Sometimes commands have to fail and you can't "oversell" as in the case of a bank withdrawal or similar value account. Or there is business logic around whether it can happen or not as in overdraft protection products, etc.

eeevans
Автор

Hi Derek, thanks for making these video. would you please make a video about difference of "Service oriented architecture and Micro service architecture"

alirezafarokhi
Автор

"this command was going to fail anyhow"... "is over-selling even an issue"... "over-selling wasn't a Sales problem, it was a Purchasing problem..."

I'd add that over-selling isn't a problem at all, over-selling is expected in this business domain and what you un-earthed through your analysis is an actual use case. Most developers spend WAY too much time focusing on the wrong problem, in this case "how can I prevent over-selling"? Not only is it impossible to prevent over-selling, but concentrating your efforts there is only going to lead to frustration and a lot of accidental complexity (plus, you're doing the business a disservice).

You don't see airlines or hotels trying to prevent over-selling. What those domains do is offer compensating actions when over-selling occurs in terms of sending a guest to a competing hotel that does have a room for them or free-flight or money-based incentives for travelers for taking a later flight. These are business processes/use cases that often get overlooked by taking a "how can I completely prevent something from happening approach".

If you take the "commands should not fail" approach, then all of the sudden, you open up a conversation with the business digging deeper into the domain and discover new uses cases that were hiding.

mikemccarthy
Автор

There certainly are business cases where commands can fail. In that cases, sort of CommandFailed event should be fired.
But of course, as in your example, some command types (or most?) should be designed such that they cannot fail.

miletacekovic
Автор

Great video, thak you for sharing! Btw, did you share the repo previously (and I missed it)?

FrequencyModulator
Автор

Hello from Russia. Thanks for your video :)

Cleannetcode
Автор

Hi Derek, thanks for making these videos. Great work. I have a question regarding events and commands after having a discussion with my work mates. In our system we receive a notification from 3rd party provider about a resource we created in their system earlier. This notification can indicate that something changed with that resource. To trigger a sync update on our side we could then either do SomethingChanged event or ChangeSomething command. But it is not really clear sometimes which to use... do you have any advice on that?

Bosslogq
Автор

Hi Derek. Thanks for the effort. I am coming from your event sourcing video and I have a question about command validation.
Suppose we just store the events ProductCountIncreased and ProductCountDecreased. Now to store the current count, a projection would replay the events and get the result. But what what about command validation. Like if currently count is 10 then a decrease command of 15 will have to fail. But we are not storing the final state. So in this case would be need to replay the events for write as well? Been searching for a long for this question

nikhilrathore
Автор

Hi Derek,

I´ve been watching your videos about loosed coupled monolith and it´s really helpful, but I still remain with a bunch of doubts related to the authonomy of the boundaries.

As far as I understood we should avoid making requests from the implementation of one boundary to the contracts of another to avoid dependencies. Sometimes it´s very hard to avoid it and I just can´t imagine a system without those dependencies. Could you clarify this?

antoniocastrojunior
Автор

Or, there's the stupid option my company made.
Take a rabbit mq and send "Request messages" having the schema of the whole process to be done - to the level of the result of each process between fail or success - and FORWARD "yes that's right, the message has the sequence of the services involved in a process where each service is going to use a chunk of that sequence- separated in dots " if you know what I mean 😉" to forward the message to the next service, and all of that happening with a consumer running in the route that published the request in the beginning "WAITING" and blocking the system waiting for the message with a response to be routed back to it, and then returning it to frontend.
Yes sir, if I say command I get shot, if I say events, I get shot, if I say rpc, which is in a way what we're doing, I get shot, if I say CQRS also I get shot, If I say aggregate I get shot, if I say whatever, I get shot.
Did we use the tool for our problem? No
Did we shove the tool onto our problem?
Yes,
Did we complicate our life for nothing, you bet we did,
And to add the cherry on top, we're doing it all in PHP, no frameworks what so ever, only php-amqplib.
What do you think of that?!!
Did we benefit from

MJ.