Model `MessageId` <- `EventId`|`RequestId` <- `QueryId`|`CommandId`
JavierCane opened this issue · comments
Based on the discussions regarding this PR.
We should model the MessageId
<- EventId
|RequestId
<- QueryId
|CommandId
hierarchy being Value Objects wrapping a Uuid
. We should also model their corresponding test stubs.
I think we should delete that RequestId coming from outside (and we could generate it directly inside every message). In order to improve the developer UX
I don't know if I'm missing anything, but if we generate the RequestId
from the inside of the backend, we will not be able to met the goal of the RequestId
: Avoid processing duplicated requests coming from the frontend.
I mean, the goal of the RequestId
parameter is helping to identify requests coming form the client which are already being processed in an asynchronous process, and successfully replying to the client without queueing again that same job.
Let's figure out that we would be modelling the communication for the AWS CodeDeploy service. The use case would be:
- Client: Hey Backend! Please, create the deploy number
123456
for the deploy groupabc
. BTW, this is the request123
. - Backend: Hey Client! I will be delighted to do so, but in an async way, so I accept your
123
request, and I would ask you to wait until I send another message through this full-duplex communication channel informing about the deploy completion - Client: Hey Backend! I'm a little bit messy implemented, so please, create the deploy number
123456
for the deploy groupabc
. BTW, this is the very same request123
. - Backed: Yep, I already heard you. I'm accepting your request because it doesn't contain any error and I have to be idempotent. However, I will not queue again that request
123
because I'm already processing it. - Some time passes
- Backend: Hey Client! Your deploy number
123456
for the deploy groupabc
has been successfully done. BTW, this response correspond to the request123
. Thanks for being listening!
That is, I completely understand the complexity added by the RequestId
while testing and modelling our request & responses. However, I find it quite useful because of being able to avoid processing duplicated requests in an async environment. So I'm completely open to any other way of implementing something else which allow us to met this very same goal, but I can't find other ways simpler than that (hashing the request parameters could be even more complex, doesn't it?) :/
Thanks!