Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit b97e8fc

Browse files
committed
last of the see also changes
1 parent c47c67e commit b97e8fc

52 files changed

Lines changed: 375 additions & 455 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/database-engine/service-broker/lesson-2-creating-an-internal-activation-procedure.md

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -22,95 +22,95 @@ In this lesson, you will learn to create a stored procedure to process messages
2222

2323
### Switch to the AdventureWorks2008R2 database
2424

25-
- Copy and paste the following code into a Query Editor window. Then, run it to switch context to the AdventureWorks2008R2 database.
26-
```
27-
USE AdventureWorks2008R2;
28-
GO
29-
```
25+
- Copy and paste the following code into a Query Editor window. Then, run it to switch context to the AdventureWorks2008R2 database.
26+
27+
```sql
28+
USE AdventureWorks2008R2;
29+
GO
30+
```
3031

3132
### Create an internal activation stored procedure
3233

33-
- Copy and paste the following code into a Query Editor window. Then, run it to create a stored procedure. When it is run, the stored procedure keeps receiving messages as long as there are messages in the queue. If the receive times out without returning a message, the stored procedure ends. If the received message was a request message, the stored procedure returns a reply message. If the received message is an **EndDialog** message, the stored procedure ends the target side of the conversation. If the received message is and **Error** message, it rolls back the transaction.
34-
```
35-
CREATE PROCEDURE TargetActivProc
36-
AS
37-
DECLARE @RecvReqDlgHandle UNIQUEIDENTIFIER;
38-
DECLARE @RecvReqMsg NVARCHAR(100);
39-
DECLARE @RecvReqMsgName sysname;
40-
41-
WHILE (1=1)
42-
BEGIN
34+
- Copy and paste the following code into a Query Editor window. Then, run it to create a stored procedure. When it is run, the stored procedure keeps receiving messages as long as there are messages in the queue. If the receive times out without returning a message, the stored procedure ends. If the received message was a request message, the stored procedure returns a reply message. If the received message is an **EndDialog** message, the stored procedure ends the target side of the conversation. If the received message is and **Error** message, it rolls back the transaction.
35+
36+
```sql
37+
CREATE PROCEDURE TargetActivProc
38+
AS
39+
DECLARE @RecvReqDlgHandle UNIQUEIDENTIFIER;
40+
DECLARE @RecvReqMsg NVARCHAR(100);
41+
DECLARE @RecvReqMsgName sysname;
4342

44-
BEGIN TRANSACTION;
43+
WHILE (1=1)
44+
BEGIN
4545

46-
WAITFOR
47-
( RECEIVE TOP(1)
48-
@RecvReqDlgHandle = conversation_handle,
49-
@RecvReqMsg = message_body,
50-
@RecvReqMsgName = message_type_name
51-
FROM TargetQueueIntAct
52-
), TIMEOUT 5000;
46+
BEGIN TRANSACTION;
47+
48+
WAITFOR
49+
( RECEIVE TOP(1)
50+
@RecvReqDlgHandle = conversation_handle,
51+
@RecvReqMsg = message_body,
52+
@RecvReqMsgName = message_type_name
53+
FROM TargetQueueIntAct
54+
), TIMEOUT 5000;
5355

54-
IF (@@ROWCOUNT = 0)
55-
BEGIN
56-
ROLLBACK TRANSACTION;
57-
BREAK;
58-
END
56+
IF (@@ROWCOUNT = 0)
57+
BEGIN
58+
ROLLBACK TRANSACTION;
59+
BREAK;
60+
END
5961

60-
IF @RecvReqMsgName =
61-
N'//AWDB/InternalAct/RequestMessage'
62-
BEGIN
63-
DECLARE @ReplyMsg NVARCHAR(100);
64-
SELECT @ReplyMsg =
65-
N'<ReplyMsg>Message for Initiator service.</ReplyMsg>';
66-
67-
SEND ON CONVERSATION @RecvReqDlgHandle
68-
MESSAGE TYPE
69-
[//AWDB/InternalAct/ReplyMessage]
70-
(@ReplyMsg);
71-
END
72-
ELSE IF @RecvReqMsgName =
73-
N'https://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
74-
BEGIN
75-
END CONVERSATION @RecvReqDlgHandle;
76-
END
77-
ELSE IF @RecvReqMsgName =
78-
N'https://schemas.microsoft.com/SQL/ServiceBroker/Error'
79-
BEGIN
80-
END CONVERSATION @RecvReqDlgHandle;
81-
END
82-
83-
COMMIT TRANSACTION;
62+
IF @RecvReqMsgName =
63+
N'//AWDB/InternalAct/RequestMessage'
64+
BEGIN
65+
DECLARE @ReplyMsg NVARCHAR(100);
66+
SELECT @ReplyMsg =
67+
N'<ReplyMsg>Message for Initiator service.</ReplyMsg>';
8468

69+
SEND ON CONVERSATION @RecvReqDlgHandle
70+
MESSAGE TYPE
71+
[//AWDB/InternalAct/ReplyMessage]
72+
(@ReplyMsg);
8573
END
86-
GO
87-
```
74+
ELSE IF @RecvReqMsgName =
75+
N'https://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
76+
BEGIN
77+
END CONVERSATION @RecvReqDlgHandle;
78+
END
79+
ELSE IF @RecvReqMsgName =
80+
N'https://schemas.microsoft.com/SQL/ServiceBroker/Error'
81+
BEGIN
82+
END CONVERSATION @RecvReqDlgHandle;
83+
END
84+
85+
COMMIT TRANSACTION;
86+
87+
END
88+
GO
89+
```
8890

8991
### Alter the target queue to specify internal activation
9092

91-
- Copy and paste the following code into a Query Editor window. Then, run it to specify that Service Broker activate the **TargetActiveProc** stored procedure to process messages from **TargetQueueIntAct**. Service Broker will run a copy of **TargetActiveProc** any time a message is received in **TargetQueueIntAct** and no copy of the procedure is already running. Service Broker will run additional copies of **TargetActiveProc** whenever the existing copies do not keep up with the number of incoming messages.
93+
- Copy and paste the following code into a Query Editor window. Then, run it to specify that Service Broker activate the **TargetActiveProc** stored procedure to process messages from **TargetQueueIntAct**. Service Broker will run a copy of **TargetActiveProc** any time a message is received in **TargetQueueIntAct** and no copy of the procedure is already running. Service Broker will run additional copies of **TargetActiveProc** whenever the existing copies do not keep up with the number of incoming messages.
9294

93-
```
94-
ALTER QUEUE TargetQueueIntAct
95-
WITH ACTIVATION
96-
( STATUS = ON,
97-
PROCEDURE_NAME = TargetActivProc,
98-
MAX_QUEUE_READERS = 10,
99-
EXECUTE AS SELF
100-
);
101-
GO
102-
```
95+
```sql
96+
ALTER QUEUE TargetQueueIntAct
97+
WITH ACTIVATION
98+
( STATUS = ON,
99+
PROCEDURE_NAME = TargetActivProc,
100+
MAX_QUEUE_READERS = 10,
101+
EXECUTE AS SELF
102+
);
103+
GO
104+
```
103105

104106
## Next Steps
107+
105108
You have successfully configured AdventureWorks2008R2 to support a conversation between the **//AWDB/InternalAct/InitiatorService** and the **//AWDB/InternalAct/TargetService**. Next, you will complete a conversation using the configuration. See [Lesson 3: Beginning a Conversation and Transmitting Messages](lesson-3-beginning-a-conversation-and-transmitting-messages.md).
106109

107110
## See also
108-
[CREATE PROCEDURE (Transact-SQL)](../../t-sql/statements/create-procedure-transact-sql.md)
109-
110-
[SEND (Transact-SQL)](../../t-sql/statements/send-transact-sql.md)
111-
112-
[RECEIVE (Transact-SQL)](../../t-sql/statements/receive-transact-sql.md)
113-
114-
[END CONVERSATION (Transact-SQL)](../../t-sql/statements/end-conversation-transact-sql.md)
115-
[Service Broker Applications](service-broker-applications.md)
116111

112+
- [CREATE PROCEDURE (Transact-SQL)](../../t-sql/statements/create-procedure-transact-sql.md)
113+
- [SEND (Transact-SQL)](../../t-sql/statements/send-transact-sql.md)
114+
- [RECEIVE (Transact-SQL)](../../t-sql/statements/receive-transact-sql.md)
115+
- [END CONVERSATION (Transact-SQL)](../../t-sql/statements/end-conversation-transact-sql.md)
116+
- [Service Broker Applications](service-broker-applications.md)

docs/database-engine/service-broker/lesson-2-creating-the-initiator-database.md

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ms.date: "03/30/2022"
1717
In this lesson, you will learn to create the initiator database and all the initiator Service Broker objects that are used in this tutorial. Run these steps from a copy of Management Studio that is running on the same computer as the initiator instance the Database Engine.
1818

1919
## Procedures
20+
2021
### Create a Service Broker endpoint
2122

2223
- Copy and paste the following code into a Query Editor window. Then, run it to create a Service Broker endpoint for this instance of the Database Engine. A Service Broker endpoint specifies the network address to which Service Broker messages are sent. This endpoint uses the Service Broker default of TCP port 4022, and specifies that remote instances of the Database Engine will use Windows Authentication connections to send messages.
@@ -64,7 +65,7 @@ In this lesson, you will learn to create the initiator database and all the init
6465

6566
- Copy and paste the following code into a Query Editor window. Change the file name that is specified in the BACKUP CERTIFICATE statement to refer to a folder on your system. Then, run the code to create the initiator certificate that is used to encrypt messages. The folder that you specify should have permissions that prevent access from accounts other than your Windows account and the Windows account the instance of the Database Engine is running under. For Lesson 3, you must manually copy the **InstInitiatorCertificate.cer** file to a folder that can be accessed from the target instance.
6667

67-
```
68+
```sql
6869
CREATE CERTIFICATE InstInitiatorCertificate
6970
AUTHORIZATION InitiatorUser
7071
WITH SUBJECT = N'Initiator Certificate',
@@ -80,7 +81,7 @@ In this lesson, you will learn to create the initiator database and all the init
8081

8182
- 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 specified here must be identical to the ones that were created in the **InstTargetDB** in the previous lesson.
8283

83-
```
84+
```sql
8485
CREATE MESSAGE TYPE [//BothDB/2InstSample/RequestMessage]
8586
VALIDATION = WELL_FORMED_XML;
8687
CREATE MESSAGE TYPE [//BothDB/2InstSample/ReplyMessage]
@@ -92,7 +93,7 @@ In this lesson, you will learn to create the initiator database and all the init
9293

9394
- 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 you will create in the **InstInitiatorDB** during the next lesson.
9495

95-
```
96+
```sql
9697
CREATE CONTRACT [//BothDB/2InstSample/SimpleContract]
9798
([//BothDB/2InstSample/RequestMessage]
9899
SENT BY INITIATOR,
@@ -106,7 +107,7 @@ In this lesson, you will learn to create the initiator database and all the init
106107

107108
- Copy and paste the following code into a Query Editor window. Then, run it to create the queue and service that is used for the target. The CREATE SERVICE statement associates the service with the **InstInitiatorQueue**. Therefore, all messages that are sent to the service will be received into the **InstInitiatorQueue**. The CREATE SERVICE also specifies that only conversations that use the **//BothDB/ 2InstSample/SimpleContract** that was created earlier can use the service as a target service.
108109

109-
```
110+
```sql
110111
CREATE QUEUE InstInitiatorQueue;
111112
112113
CREATE SERVICE [//InstDB/2InstSample/InitiatorService]
@@ -119,7 +120,7 @@ In this lesson, you will learn to create the initiator database and all the init
119120

120121
- Copy and paste the following code into a Query Editor window. Change the FROM FILE clause to reference the folder to which you copied the **InstTargetCertficate.cer** file from step 3 in Lesson 1. Then, run the code to create a target user and pull in the target certificate.
121122

122-
```
123+
```sql
123124
CREATE USER TargetUser WITHOUT LOGIN;
124125
125126
CREATE CERTIFICATE InstTargetCertificate
@@ -135,7 +136,7 @@ In this lesson, you will learn to create the initiator database and all the init
135136

136137
The following CREATE ROUTE statements assume that there are no duplicate service names in the target instance. If multiple databases on the target instance have services with the same name, use the BROKER_INSTANCE clause to specify the database on which you want to open a conversation.
137138

138-
```
139+
```sql
139140
DECLARE @Cmd NVARCHAR(4000);
140141
141142
SET @Cmd = N'USE InstInitiatorDB;
@@ -163,39 +164,25 @@ In this lesson, you will learn to create the initiator database and all the init
163164
```
164165

165166
## Next Steps
167+
166168
You have successfully created the initiator databases that will be used for the tutorial. Next, you will finish configuring the target database by creating the target objects that have dependencies on initiator objects. See [Lesson 3: Completing the Target Conversation Objects](lesson-3-completing-the-target-conversation-objects.md).
167169

168170
## See also
169-
[BACKUP CERTIFICATE (Transact-SQL)](../../t-sql/statements/backup-certificate-transact-sql.md)
170-
171-
[CREATE CERTIFICATE (Transact-SQL)](../../t-sql/statements/create-certificate-transact-sql.md)
172-
173-
[CREATE CONTRACT (Transact-SQL)](../../t-sql/statements/create-contract-transact-sql.md)
174-
175-
[CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md)
176-
177-
[CREATE ENDPOINT (Transact-SQL)](../../t-sql/statements/create-endpoint-transact-sql.md)
178-
179-
[CREATE MASTER KEY (Transact-SQL)](../../t-sql/statements/create-master-key-transact-sql.md)
180-
181-
[CREATE MESSAGE TYPE (Transact-SQL)](../../t-sql/statements/create-message-type-transact-sql.md)
182-
183-
[CREATE QUEUE (Transact-SQL)](../../t-sql/statements/create-queue-transact-sql.md)
184-
185-
[CREATE REMOTE SERVICE BINDING (Transact-SQL)](../../t-sql/statements/create-remote-service-binding-transact-sql.md)
186-
187-
[CREATE ROUTE (Transact-SQL)](../../t-sql/statements/create-route-transact-sql.md)
188-
189-
[CREATE SERVICE (Transact-SQL)](../../t-sql/statements/create-service-transact-sql.md)
190-
191-
[CREATE USER (Transact-SQL)](../../t-sql/statements/create-user-transact-sql.md)
192-
193-
[EXECUTE (Transact-SQL)](../../t-sql/language-elements/execute-transact-sql.md)
194-
195-
[sp_addlinkedserver (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-addlinkedserver-transact-sql.md)
196-
[Service Broker Dialog Security](service-broker-dialog-security.md)
197-
198-
[Conversation Architecture](conversation-architecture.md)
199-
200-
[Service Architecture](service-architecture.md)
201171

172+
- [BACKUP CERTIFICATE (Transact-SQL)](../../t-sql/statements/backup-certificate-transact-sql.md)
173+
- [CREATE CERTIFICATE (Transact-SQL)](../../t-sql/statements/create-certificate-transact-sql.md)
174+
- [CREATE CONTRACT (Transact-SQL)](../../t-sql/statements/create-contract-transact-sql.md)
175+
- [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md)
176+
- [CREATE ENDPOINT (Transact-SQL)](../../t-sql/statements/create-endpoint-transact-sql.md)
177+
- [CREATE MASTER KEY (Transact-SQL)](../../t-sql/statements/create-master-key-transact-sql.md)
178+
- [CREATE MESSAGE TYPE (Transact-SQL)](../../t-sql/statements/create-message-type-transact-sql.md)
179+
- [CREATE QUEUE (Transact-SQL)](../../t-sql/statements/create-queue-transact-sql.md)
180+
- [CREATE REMOTE SERVICE BINDING (Transact-SQL)](../../t-sql/statements/create-remote-service-binding-transact-sql.md)
181+
- [CREATE ROUTE (Transact-SQL)](../../t-sql/statements/create-route-transact-sql.md)
182+
- [CREATE SERVICE (Transact-SQL)](../../t-sql/statements/create-service-transact-sql.md)
183+
- [CREATE USER (Transact-SQL)](../../t-sql/statements/create-user-transact-sql.md)
184+
- [EXECUTE (Transact-SQL)](../../t-sql/language-elements/execute-transact-sql.md)
185+
- [sp_addlinkedserver (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-addlinkedserver-transact-sql.md)
186+
- [Service Broker Dialog Security](service-broker-dialog-security.md)
187+
- [Conversation Architecture](conversation-architecture.md)
188+
- [Service Architecture](service-architecture.md)

docs/database-engine/service-broker/lesson-2-creating-the-target-conversation-objects.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,13 @@ In this lesson, you will learn to build all the objects that enable a database t
6565
```
6666

6767
## Next Steps
68+
6869
You have successfully configured **TargetDB** to support a conversation between it and the **InitiatorDB**. Next, you will configure the **InitiatorDB** to initiate a conversation to the **TargetDB**. See [Lesson 3: Creating the Initiator Conversation Objects](lesson-3-creating-the-initiator-conversation-objects.md).
6970

7071
## See also
71-
[CREATE MESSAGE TYPE (Transact-SQL)](../../t-sql/statements/create-message-type-transact-sql.md)
72-
73-
[CREATE CONTRACT (Transact-SQL)](../../t-sql/statements/create-contract-transact-sql.md)[CREATE QUEUE (Transact-SQL)](../../t-sql/statements/create-queue-transact-sql.md)
74-
75-
[CREATE SERVICE (Transact-SQL)](../../t-sql/statements/create-service-transact-sql.md)
76-
[Conversation Architecture](conversation-architecture.md)
77-
78-
[Service Architecture](service-architecture.md)
7972

73+
- [CREATE MESSAGE TYPE (Transact-SQL)](../../t-sql/statements/create-message-type-transact-sql.md)
74+
- [CREATE CONTRACT (Transact-SQL)](../../t-sql/statements/create-contract-transact-sql.md)[CREATE QUEUE (Transact-SQL)](../../t-sql/statements/create-queue-transact-sql.md)
75+
- [CREATE SERVICE (Transact-SQL)](../../t-sql/statements/create-service-transact-sql.md)
76+
- [Conversation Architecture](conversation-architecture.md)
77+
-[Service Architecture](service-architecture.md)

docs/database-engine/service-broker/lesson-3-beginning-a-conversation-and-transmitting-messages.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ms.date: "03/30/2022"
1717
In this lesson, you will learn to complete a simple request-reply message cycle in a system configured with an internal activation stored procedure.
1818

1919
## Procedures
20+
2021
### Switch to the AdventureWorks2008R2 database
2122

2223
[!INCLUDE [SQL Server Service Broker AdventureWorks2008R2](../../includes/service-broker-adventureworks-2008-r2.md)]
@@ -96,15 +97,13 @@ In this lesson, you will learn to complete a simple request-reply message cycle
9697
- When you run the END CONVERSATION statement for the initiator, Service Broker sends an **EndDialog** message to the **TargetQueueIntAct** queue. The **TargetActiveProc** procedure receives the **EndDialog** message and issues an END CONVERSATION that ends the target side of the conversation.
9798
9899
## Next Steps
100+
99101
You have successfully completed a request-reply message cycle between the **//AWDB/InternalAct/InitiatorService** and the **//AWDB/InternalAct/TargetService**. You can repeat the steps in this lesson as many times as you want to transmit a request-reply pair of messages. When you have finished investigating the SEND and REPLY statements, you can drop all the objects that were used by the conversation. For more information, see [Lesson 4: Dropping the Conversation Objects](lesson-4-dropping-the-conversation-objects.md).
100102
101103
## See also
102-
[BEGIN DIALOG CONVERSATION (Transact-SQL)](../../t-sql/statements/begin-dialog-conversation-transact-sql.md)
103-
104-
[SEND (Transact-SQL)](../../t-sql/statements/send-transact-sql.md)
105-
106-
[RECEIVE (Transact-SQL)](../../t-sql/statements/receive-transact-sql.md)
107-
108-
[END CONVERSATION (Transact-SQL)](../../t-sql/statements/end-conversation-transact-sql.md)
109-
[Service Broker Applications](service-broker-applications.md)
110104
105+
- [BEGIN DIALOG CONVERSATION (Transact-SQL)](../../t-sql/statements/begin-dialog-conversation-transact-sql.md)
106+
- [SEND (Transact-SQL)](../../t-sql/statements/send-transact-sql.md)
107+
- [RECEIVE (Transact-SQL)](../../t-sql/statements/receive-transact-sql.md)
108+
- [END CONVERSATION (Transact-SQL)](../../t-sql/statements/end-conversation-transact-sql.md)
109+
- [Service Broker Applications](service-broker-applications.md)

0 commit comments

Comments
 (0)