Search code examples
msmqwcf-data-services

WCF Data Services and MSMQ


I've got a database which contains an Order table. I'm trying to create an API for our clients so they can manipulate the data within the Order table. I have chosen to go down the route of a WCF Data Service so that clients can perform CRUD operation via URI's.

However I need to ensure this WCF Data Service is scalable and can handle a large number of requests(1000) made from multiple clients. I've looked at using MSMQ with WCF Data services but looking at the following link this seems impossible - Can we use msmq messaging with wcf data service.

My work around is when a client attempts to manipulate the data (not selects), instead of waiting for the changes to be saved to the db we add the request to a MSMQ. This is done by overriding the SaveChanges() method in the ORM and extracting the changes, serialise them into the MSMQ and then return to the client. A separate thread will then pull objects from the MSMQ and then save the changes to the db.

This all seem fine but how do I notify the client that its request has been processed or errored. Any ideas?


Solution

  • Any offline processing of a usually synchronous operation will incur this problem.

    It is one of the problems faced when implementing CQRS pattern, which attempts to decouple reads and write operations. This has been termed eventual consistency.

    There are actually many different techniques for addressing this problem - have a look at these links:

    CQRS - Eventual Consistency

    GUI recommandations for eventual consistency?