This sample shows a simple, stateless application that uses the ServiceBrokerInterface sample.

Building and Installing the sample

  1. CD to the install directory and execute the following at a .NET Framework or Microsoft Visual Studio 2005 command prompt:

    sn -k samplekey.snk

  2. In Visual Studio 2005, open HelloWorldCS.sln or HelloWorldVB.sln.

  3. Build the solution by pressing F6, or by selecting Build Solution from the Build menu.

  4. Run Install.cmd, located within the Scripts folder of the HelloWorld_CLR directory. This file sets up the environment, then executes the Install.sql install script. If you built the Visual Basic version of the project, you might have to change the "cs" in the path for the assembly to "vb" in the Install.sql script.

Running the sample

  1. Run the HelloWorldClient.exe console application from the sample directory. To exit the client, press Enter after the client shows the response.

Requirements

This sample requires Visual Studio 2005. Because the sample uses features of the common language runtime that were not available in earlier versions, released versions of Visual Studio cannot build the sample.

Demonstrates

This sample demonstrates use of the sample object-oriented programming interface provided in the Service Broker Interface sample. All Service Broker functionality for the sample uses the Service Broker Interface.

There are two main parts of the sample: a client program that runs outside of SQL Server, and a common language runtime stored procedure that implements the service.

The external program begins a conversation from the service HelloWorldClient to the service HelloWorldService, then sends a message on that conversation. This application sends a Request message to the service HelloWorldService. The activated stored procedure receives and responds to the message. The client receives a response, shows the response on the console, and then ends the dialog.

The common language runtime stored procedure implements the HelloWorldService. Service Broker activates this procedure. The procedure reads a message from the queue. For a Request message, the procedure responds with a Response message. For a Service Broker end dialog message, the procedure ends the conversation.