in Education by
This one will take some explaining. What I've done is create a specific custom message queue in SQL Server 2005. I have a table with messages that contain timestamps for both acknowledgment and completion. The stored procedure that callers execute to obtain the next message in their queue also acknowledges the message. So far so good. Well, if the system is experiencing a massive amount of transactions (thousands per minute), isn't it possible for a message to be acknowledged by another execution of the stored procedure while another is prepared to so itself? Let me help by showing my SQL code in the stored proc: --Grab the next message id declare @MessageId uniqueidentifier set @MessageId = (select top(1) ActionMessageId from UnacknowledgedDemands); --Acknowledge the message update ActionMessages set AcknowledgedTime = getdate() where ActionMessageId = @MessageId --Select the entire message ... ... In the above code, couldn't another stored procedure running at the same time obtain the same id and attempt to acknowledge it at the same time? Could I (or should I) implement some sort of locking to prevent another stored proc from acknowledging messages that another stored proc is querying? Wow, did any of this even make sense? It's a bit difficult to put to words... JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Something like this --Grab the next message id begin tran declare @MessageId uniqueidentifier select top 1 @MessageId = ActionMessageId from UnacknowledgedDemands with(holdlock, updlock); --Acknowledge the message update ActionMessages set AcknowledgedTime = getdate() where ActionMessageId = @MessageId -- some error checking commit tran --Select the entire message ... ...

Related questions

0 votes
    In order to create the proper queries I need to be able to run a query against the same datasource ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I'm trying to do a SQL Server 2008 setup and I've been given a Cross Language Installation failure ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm trying to do a SQL Server 2008 setup and I've been given a Cross Language Installation failure ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    In SQL Server, it's possible to insert into a table using a SELECT statement: INSERT INTO Table (col1, col2, ... .id = other_table.id Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I need to remove a highly referenced table in a SQL Server database. How can I get a list of all the ... of the management studio.) Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I have seen SQL that uses both != and for not equal. What is the preferred syntax and why? I like !=, ... reminds me of Visual Basic. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    Could someone tell me what I should learn to become a SQL Developer? Select the correct answer from above options...
asked Jan 6, 2022 in Education by JackTerrance
0 votes
    I have tried and tried, and can not get linked. I can connect to the server using SSMS, but can not link to ... = '[password]' GO Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Could anybody tell me where I can learn Microsoft SQL Server? Select the correct answer from above options...
asked Jan 6, 2022 in Education by JackTerrance
0 votes
    We have a customer requesting data in XML format. Normally this is not required as we usually just hand ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    We have a customer requesting data in XML format. Normally this is not required as we usually just hand ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    How do I perform an IF...THEN in an SQL SELECT statement? For example: SELECT IF(Obsolete = 'N' OR ... Saleable, * FROM Product Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I have a store to get a list of something in system. To get information by business requirement, this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I didn't see any similar questions asked on this topic, and I had to research this for something I'm working ... had the same question. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I didn't see any similar questions asked on this topic, and I had to research this for something I'm working ... had the same question. Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
...