views:

151

answers:

1

Hi All,

Let me define the problem first and why a messagequeue has been chosen. I have a datalayer that will be transactional and EXTREMELY insert heavy and rather then attempt to deal with these issues when they occur I am hoping to implement my application from the ground up with this in mind.

I have decided to tackle this problem by using the Microsoft Message Queue and perform inserts as time permits asynchronously. However I quickly ran into a problem. Certain inserts that I perform may need to be recalled (ie: retrieved) immediately (imagine this is for POS system and what happens if you need to recall the last transaction - one that still hasn’t been inserted).

The way I decided to tackle this problem is by abstracting the MessageQueue and combining it in my data access layer thereby creating the illusion of a single set of data being returned to the user of the datalayer (I have considered the other issues that occur in such a scenario (ie: essentially dirty reads and such) and have concluded for my purposes I can control these issues).

However this is where things get a little nasty... I’ve worked out how to get the messages back and such (trivial enough problem) but where I am stuck is; how do I create a generic (or at least somewhat generic) way of querying my message queue? One where I can minimize the duplication between the SQL queries and MessageQueue queries. I have considered using LINQ (but have very limited understanding of the technology) and have also attempted an implementation with Predicates which so far is pretty smelly.

Are there any patterns for such a problem that I can utilize? Am I going about this the wrong way? Does anyone have any of their own ideas about how I can tackle this problem? Does anyone even understand what I am talking about? :-)

Any and ALL input would be highly appreciated and seriously considered…

Thanks again.

For anyone interested. I decided in the end to simply cache the transaction in another location and use the MSMQ as intended and described below.

+1  A: 

If the queue has a large-ish number of messages on it, then enumerating those messages will become a serious bottleneck. MSMQ was designed for first-in-first-out kind of access and anything that doesn't follow that pattern can cause you lots of grief in terms of performance.

The answer depends greatly on the sort of queries you're going to be executing, but the answer may be some kind of no-sql database (CouchDB or BerkeleyDB, etc)

Dean Harding
Hi Codeka, Thank you for the response. Could you define "large-ish"? My intent is to run a seperate server for the messagequeue. Does this in any way change your response? Lastly the queries that this scenario I am discribing will mostly be running is very simple select statements along the lines of..SELECT * FROM RegisterTransactionHeader INNER JOIN RegisterTransactionDetail ....Thanks again
Maxim Gershkovich
The location of the queue doesn't really affect it. It's mostly just the act of enumerating all the messages. As with anything performance-related, it's hard to give a hard-and-fast answer, but I would say if you had more than 100 or so messages then you're likely to start to notice it. You also have to take into account the fact that as you're enumerating messages, other processes will be taking messages off, so that can complicate the situation as well.
Dean Harding