Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Azure SQL Managed Instance
In this lesson, you learn to build all the objects that enable a database to initiate a conversation with another database.
Procedures
Switch to the InitiatorDB database
Copy and paste the following code into a Query Editor window, then run it to switch context to the InitiatorDB database.
USE InitiatorDB; GO
Create the message types
Copy and paste the following code into a Query Editor window, then run it to create the message types for the conversation. The message type names and properties that are specified here must be identical to the ones that were created in the TargetDB in the previous lesson.
CREATE MESSAGE TYPE [//BothDB/2DBSample/RequestMessage] VALIDATION = WELL_FORMED_XML; CREATE MESSAGE TYPE [//BothDB/2DBSample/ReplyMessage] VALIDATION = WELL_FORMED_XML; GO
Create the contract
Copy and paste the following code into a Query Editor window, then run it to create the contract for the conversation. The contract name and properties that are specified here must be identical to the contract that was created in the TargetDB in the previous lesson.
CREATE CONTRACT [//BothDB/2DBSample/SimpleContract] ([//BothDB/2DBSample/RequestMessage] SENT BY INITIATOR, [//BothDB/2DBSample/ReplyMessage] SENT BY TARGET); GO
Create the initiator queue and service
Copy and paste the following code into a Query Editor window, then run it to create the queue and service that's used for the initiator. Because no contract name is specified, no other services can use this service as a target service.
CREATE QUEUE InitiatorQueue2DB; CREATE SERVICE [//InitDB/2DBSample/InitiatorService] ON QUEUE InitiatorQueue2DB; GO
Related content
- CREATE MESSAGE TYPE (Transact-SQL)
- CREATE CONTRACT (Transact-SQL)
- CREATE QUEUE (Transact-SQL)
- CREATE SERVICE (Transact-SQL)
- Conversation architecture
- Service architecture
Next step
You've successfully configured the InitiatorDB and TargetDB to support a conversation between the two databases. Next, you complete a conversation that uses the configuration.