1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| ALTER PROCEDURE spSB_get_patient_from_queue
AS
BEGIN
SET NOCOUNT ON
DECLARE @conversation_handle uniqueidentifier
, @message_body xml(monSchemaXML)
WHILE (1 = 1) -- Process all the messages received by the queue
BEGIN
-- Début transaction
BEGIN TRANSACTION;
WAITFOR
(
RECEIVE TOP (1) @conversation_handle = conversation_handle
, @message_body = CAST(message_body AS xml(monSchemaXML))
FROM dbo.maPile
) -- TIMEOUT 6000 --> attente 6s
IF @@ROWCOUNT > 0
BEGIN
INSERT INTO dbo.maTable
...
FROM @message_body.nodes('/node') AS MB(c)
END
END CONVERSATION @conversation_handle
-- Validation transaction
COMMIT TRANSACTION;
END
GO |
Partager