Back To Basics: Service Broker Services

Services are used to bind contracts to queues.  They are also used to database to database, or server to server routing of messages via routes (we’ll talk about them later).  Unlike most other objects within SQL Server, the name of the service is case sensitive, no matter what collation you have set for your database.  When using server to server queueing the service names must be identical, including case as SQL Servers uses a hash of the service name to locate the correct service.

(Service names are not actually case sensitive if you arne’t using routing, but if you are going to start routing the messages later it’s better to start off getting them in the correct case.)

The syntax to create the service is pretty straight forward.

CREATE SERVICE ServiceName
ON QUEUE QueueName (ContractName)

If the service will only be the initiator then the contract name can be omited if preferred.  If you want to create a multi-user contact you can specify additional contracts by simply making a comma seperated list of contract names.

CREATE SERVICE ServiceName
ON QUEUE QueueName;

CREATE SERVICE ServiceName
ON QUEUE QueueName (ContractName1, ContractName2);

Denny

Share

Leave a Reply

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?