Back To Basics: Service Broker Contracts

Every Service Broker conversation requires a contract.  The contract defines which message type or types will be used, as well as who (sender or receiver) can use which message types.  The contract is specified when the conversation is created.

The syntax for creating the contract is pretty straight forward.

CREATE CONTRACT [ContractName]
(MessageType SENT BY ANY)

The SEND BY portion can be used as many times as is needed for each Message Type which is defined on the contract.  It must be listed at least once as you can not have a contract with no message types.  You can specify that the Message Type be used by the INITIATOR, the TARGET or by both (by using the ANY keyword).

A more complex Contract would look something like this.

CREATE CONTRACT [ContractName]
(MessageType_I SENT BY INITIATOR,
MessageType_T SENT BY TARGET)

Denny

Share

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trust DCAC with your data

Your data systems may be treading water today, but are they prepared for the next phase of your business growth?