Service bus brokered messages -> worker role -> SQL Azure prevent entering data in less than 30 min
-
Saturday, April 28, 2012 9:12 AM
Hi,
I have a client win forms application that allows users to enter manually data to sql azure.
The condition is:
- one user can enter only one time in 30 min one entry with the same subject
Example:

When user click's save data, behind is created a Message entity and sent to Azure service bus queue. In windows azure there is a worker role that check for new messages in the queue. If message found, process that message and save's it to SQL Azure database.
What is the best way to ensure that one message sent from the same user with the same subject is not entered more than 1 in less than 30 min.
Is there a way to make this at the client application level, or I should check this at the worker role side?
How can I ensure that the message with the same subject is not entered twice by the same user in the database?
The database table is something like:
id subject message enter time
---------------------------------------------------------------------------------------------------------
username subject1 message1 2012-02-08 15:05:35.963
Thanks!
P.S. There are hundreds of users running this client application and save that data to SQL Azure ...
And yes, SQL Azure not Table storage.
- Edited by Alex.Sm Saturday, April 28, 2012 9:14 AM
All Replies
-
Saturday, April 28, 2012 5:21 PMModerator
Hi,
According to description, I'd like to suggestion with following solutions:
1. SQL Azure table. I note you have "enter time" data colums in that table, would you like to check the lastest rows with "enter time"? You can add a row "Update by user" (insert the user who add data into SQL Azure), the application will query the user's latest add operation time and check if the time interval is longer than 30 mins. If yes, allow this operation.
2. Azure VM. When users commit the add operation of SQL Azure success, record (or modify) current datetime in user's session as a KEY/VALUE, and the application can rely on this time to allow/reject the add request from users.
Hope this helps.
Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
- Marked As Answer by Arwind - MSFTModerator Friday, May 04, 2012 7:42 AM
-
Sunday, April 29, 2012 12:48 AM
You can prevent all duplicate user+subject entries in SQL Azure by creating a unique index on those two columns. Something like this:
CREATE UNIQUE NONCLUSTERED INDEX [YourIndexName]
ON [YourTable]
([Id], [Subject])If you allow duplicates after the 30 minute time window, then you'll need to write some code (.NET or T-SQL) to do the check. A stored procedure would be the usual place for that kind of thing.
Check out my book: Ultra-fast ASP.NET: Building Ultra-Fast and Ultra-Scalable Websites using ASP.NET and SQL Server
- Marked As Answer by Arwind - MSFTModerator Friday, May 04, 2012 7:42 AM

