BEGIN CONVERSATION TIMER (Transact-SQL)
Starts a timer. When the time-out expires, Service Broker puts a message of type http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer on the local queue for the conversation.
A conversation timer provides a way for an application to receive a message on a conversation after a specific amount of time. Calling BEGIN CONVERSATION TIMER on a conversation before the timer has expired sets the timeout to the new value. Unlike the conversation lifetime, each side of the conversation has an independent conversation timer. The DialogTimer message arrives on the local queue without affecting the remote side of the conversation. Therefore, an application can use a timer message for any purpose.
For example, you can use the conversation timer to keep an application from waiting too long for an overdue response. If you expect the application to complete a dialog in 30 seconds, you might set the conversation timer for that dialog to 60 seconds (30 seconds plus a 30-second grace period). If the dialog is still open after 60 seconds, the application receives a time-out message on the queue for that dialog.
Alternatively, an application can use a conversation timer to request activation at a particular time. For example, you might create a service that reports the number of active connections every few minutes, or a service that reports the number of open purchase orders every evening. The service sets a conversation timer to expire at the desired time; when the timer expires, Service Broker sends a DialogTimer message. The DialogTimer message causes Service Broker to start the activation stored procedure for the queue. The stored procedure sends a message to the remote service and restarts the conversation timer.
BEGIN CONVERSATION TIMER is not valid in a user-defined function.
The following example sets a two-minute time-out on the dialog identified by @dialog_handle.
-- @dialog_handle is of type uniqueidentifier and -- contains a valid conversation handle. BEGIN CONVERSATION TIMER (@dialog_handle) TIMEOUT = 120 ;