The Hello World sample provides a simple Service Broker application that shows you how to send and receive a message by using Service Broker.

By default, the Hello World sample application is installed at C:\Program Files\Microsoft SQL Server\100\Samples\Engine\\ServiceBroker\HelloWorld. If the sample folder is not present, see Installing Samples.

Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator.

  1. Open the project file in SQL Server Management Studio.

  2. Run Setup.sql. This script creates the Service Broker objects for the services.

  3. Open SendMessage.sql, select all lines from the beginning of the file to the comment ‘End Selection Here' and run selected part of the script. This part of the script begins a dialog conversation from InitiatorService to TargetService and sends a message on this conversation.

  4. Run ReceivesMessages.sql. This script receives Service Broker messages from the TargetQueue, displays the messages and ends the corresponding conversations at the target.

  5. Open SendMessage.sql, select all lines from the comment ‘End Selection Here' to the end of the file and run selected part of the script. This part of the script waits for a response message, displays the message and ends the corresponding conversation at the initiator.

Community Additions