I have to design a system of clients connecting to WCF service(s) to perform read and write operations on a database, and also get notifications.
I was told to use CQRS pattern.
For the sake of an example, clients will connect to a service to perform operations like Get List Of Products and Update Product. They will also be able to do something like Accept Shipment and Reject Shipment (which might cause a race between clients who is the one to do it first). Only one client can 'accept' a shipment or 'reject' a shipment.
So I read a little bit about CQRS and understood it decouples the reads from the writes (using commands). However, I am not sure about a few major issues if I use CQRS :
If I use CQRS pattern on the WCF service - can I count on things being done synchronously on the database ? I am a bit confused, cause I don't want the service to be single threaded (to support future scalability), but on the other hand - how do I make sure that write operations on the service are performed in the right order ? or even read operations ? Does the CQRS pattern guarantee ordered processing ? (someone told me here that CQRS pattern uses an 'update' queue to update requests for offline processing).
Does using CQRS eliminate concurrency problems ?
Should I still use 'TransactionScope' in all my command handlers that interact with the database ?
I have spent more than a week in trying to understand how to implement the notifications service for the clients, with no luck. I have this design:
'Product Service' will be a CQRS service, but I have trouble with the notifications service. The client may send a command to the product service to be notified about products of category X. This command will update the request in the database. Let's say for now that the notification service polls the database every 15 minutes, and checks which user wanted to be polled on which category and then sends new products to users that requested to be notified on those product's categories. What happens now if a user changes a category for a product and 20 other users already see this product in their notification window ? I need some way to detect that the product is no longer of that category, and to send them a notification like 'remove that product from your view'. This doesn't sound so much like notifications. It sounds more like 'Request a CONSTANT RELEVANT view of a database table, and every change should be reflected to the client's screen'. How do I do this kind notification service ??