thenativeweb / node-cqrs-eventdenormalizer

Node-cqrs-eventdenormalizer is a node.js module that implements the cqrs pattern. It can be very useful as eventdenormalizer component if you work with (d)ddd, cqrs, domain, host, etc.
http://cqrs.js.org/pages/eventdenormalizer.html
MIT License
38 stars 27 forks source link

[Question] how to handle Binaries? #52

Closed AlexandreRoba closed 8 years ago

AlexandreRoba commented 8 years ago

Dear All,

I have setuped a domain that requires to store binaries. For this I have applied the ClaimCheck pattern.

Meaning when I want to submit a command that should contains a binary, I replace the binaries on the command with the claim provided from the claimcheck service. I then process the command and the event applied has also the claim check id.

Now from the readmodel. When I receive the event with the claim check. I need to retrieve back the binary from the claim check in order to save the binary on the read model repository in eventually a dedicated collection. I was wondering if you have any recommendation on that scenario? I could of course keep the binary on the claimcheck service and I have to in order to be able to replay all the events. But I would like to avoid to server the binaries for the readmodel from there. I mean... The read model should depends only on its own storage and not on the availability of another service.

I'm open to any clean and smart suggestion :)

adrai commented 8 years ago

I would not recommend to send binary data in command or events... (You don't need to solve everything with cqrs)

I would upload your binaries on a separate blob service and only send the appropriate id(s) in the command/event

AlexandreRoba commented 8 years ago

Yep. I agree. This is why I have implemented the ClaimCheckServer. The only information on the command is the claimcheckid. the binary is uploaded on the claimcheck blob storage. But then, once the event (containing the claimid) is captured by the viewmodel, ideally I should download the binary from the claimchekservice and save it on the readmodel storage. I was wondering when I denormalize the events on the eventdenormalizer it should grad the binary from the claimcheckserver and save it on the collection. today the collection are structure based. I was wondering if there is a way to define view model on mongo GridFs or something...

adrai commented 8 years ago

GridFs... not right now... but can't you serve/proxy your binaries from your process/host that wraps the readmodel?

AlexandreRoba commented 8 years ago

I could, but then I have another issue. The access right. The claimserver is a server to server service. If it is exposed to the client then it needs to manage the access rights... which should be managed at the view model for the givne scenario.

AlexandreRoba commented 8 years ago

Ok forget about what I said. I can indeed use the viewmodel to proxy the access to the claimcheck service. I then have a the security set at the viewmodel api. thanks for your help.