Chris Johnson is working on a series on Service Broker fundamentals. This post covers conversations and messages:
First, each conversation has its own unique dialog_handle (not conversation handle, despite everything calling it a conversation from now on, score one for consistency Microsoft). We need to capture this handle in a
UNIQUEIDENTIFIERvariable, as we will need it later on to send messages across the conversation. In fact, the statement will error if you don’t supply a variable to capture the handle.
Second, we need to supply both
TOservices. These tell the conversation which service is the source and which is the target. Remember, each service is attached to a queue, and can have one or more contracts attached to it. The source service is a database object, but the target service is an
NVARCHAR. This allows the target service to live outside the database, which is something that I will cover at some point in the Service Broker 201 series.
This is a nice explanation of the process, so if you aren’t particularly familiar with Service Broker, check out Chris’s series, starting with the first and second posts.