Service Broker Question - End Conversation command

  • Does "END CONVERSATION" send a message back to the actual queues?

    The reason I'm asking is due to some code I've been looking through. There's doesn't seem to be a normal reply message to send a message back to the initiator, but a stored procedure linked to the initiator queue is definitely being triggered somehow.

    I've even looked through a trace and the stored procedure linked to the initiator queue is started right after the END CONVERSATION command and the CLOSED Broker:Conversation.

  • Yes.

    The probability of survival is inversely proportional to the angle of arrival.

  • hi,

    ending a conversation on the target DOES send a message back to the initiator.

    For testing I recommend creating the queue on the initiator without any stored procedure. This way the messages remain in the queue and you can have a look at it quite convenient.

  • Thanks. Out of interest, do the sp's exec when a message is received into the queue, or when it's read from the queue? My testing seems to indicate it's when read from the queue. Slightly confused by the MSDN article:

    STATUS (Activation):

    Specifies whether Service Broker starts the stored procedure. When STATUS = ON, the queue starts the stored procedure specified with PROCEDURE_NAME when the number of procedures currently running is less than MAX_QUEUE_READERS and when messages arrive on the queue faster than the stored procedures receive messages

  • The documentation is correct, the activation procedure is executed when a message arrives on the queue.

    Of course this only occurs if the queue has activation enabled (turned on) and an activation procedure set up. If activation is OFF then any number of messages can build up until some process starts reading them from the message queue.

    The probability of survival is inversely proportional to the angle of arrival.

  • Thanks guys.

    I created a test service broker and 2 stored procedures. The 1st sp was linked to the response queue and basically read the message and then ended the conversation. The 2nd sp was linked to the initiator queue and read the returned end conversation message. I manually sent the initial message, and sure enough both sp's are shown as executed in sys.dm_exec_procedure_stats

    This explains why I couldn't see a response message in the t-sql code, but both sp's where being executed.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply