SQL Server Service Borker 1

來源:互聯網
上載者:User

標籤:blog   http   io   ar   使用   for   sp   strong   資料   

1、訊息類型定義:

  訊息類型,是資訊交換的模板、create message type message_type_name validattion = well_formed_xml;

2、約定定義:

  約定,指示任務使用的訊息 create contract contract_name (message_type_name sent by initiator |target | all [....]);

3、隊列定義:

  隊列是資訊的集合: create queue queue_name with status = on;

4、服務定義:

  服務定義連接埠用來把訊息綁定到一個或多個約定上 create service service_name on queue queue_name(contract_name_list);

例子:

create database bookstore;
create database bookdistribution;

----時間執行者目的

----2014-10-30蔣樂建立兩個資料庫用於測試 service broker!
go

use bookstore;

alter database bookstore
set enable_broker;

alter database bookstore
set trustworthy on;

create master key
encryption by password =‘123456‘;

----時間執行者目的

----2012-10-30蔣樂配製資料庫的 3(enable_broker\trustworthy\master key) 個選項使它支援 service borker
go

use bookdistribution;

alter database bookdistribution
set enable_broker;

alter database bookdistribution
set trustworthy on;

create master key
encryption by password = ‘123456‘;


----時間執行者目的

----2012-10-30蔣樂配製資料庫的 3(enable_broker\trustworthy\master key) 個選項使它支援 service borker

go

use bookstore;

create message type [send_to_distribution]
validation = well_formed_xml;

create message type [send_to_distribution_received]
validation = well_formed_xml;

create contract [send_to_distribution_contract](
[send_to_distribution] sent by initiator,
[send_to_distribution_received] sent by target);

----時間執行者目的

----2012-10-30蔣樂定義訊息類型與約定、(注意在兩個相互連信的資料庫中
--要有一樣的訊息類型與約定才可以通訊。
go

use bookdistribution;

create message type [send_to_distribution]
validation = well_formed_xml;

create message type [send_to_distribution_received]
validation = well_formed_xml;

create contract [send_to_distribution_contract](
[send_to_distribution] sent by initiator,
[send_to_distribution_received] sent by target);

----時間執行者目的

----2012-10-30蔣樂定義訊息類型與約定。
go


use bookstore;

create queue [send_to_bookdistribution_queue]
with
status = on;


----時間執行者目的

----2012-10-30蔣樂定義隊列
go

use bookdistribution;

create queue [send_to_bookdistribution_queueBookDistribution]
with
status = on;

 

----時間執行者目的

----2012-10-30蔣樂定義隊列
go


use bookstore;

create service [send_to_distribution_service_bookstore]
on queue send_to_bookdistribution_queue(send_to_distribution_contract);

 

----時間執行者目的

----2012-10-30蔣樂定義服務
go


use bookdistribution

create service [send_to_distribution_service_bookdistribution]
on queue send_to_bookdistribution_queueBookDistribution(send_to_distribution_contract);


----時間執行者目的

----2012-10-30蔣樂定義服務
go


use bookstore;

declare @handle uniqueidentifier;
declare @message xml;

begin dialog conversation @handle
from service send_to_distribution_service_bookstore
to service ‘send_to_distribution_service_bookdistribution‘ -- ! _ ! -- :因為它定義在別的資料庫中、所以不可以用名字。要用字串。
on contract send_to_distribution_contract;

set @message = ‘<Person>11436101</Person>‘;

send on conversation @handle message type send_to_distribution
(@message);


----時間執行者目的

----2012-10-30蔣樂發送一個非同步訊息
go


use bookdistribution;

select * from dbo.send_to_bookdistribution_queueBookDistribution;

----時間執行者目的

----2012-10-30蔣樂查看發送過來的訊息
go

 

SQL Server Service Borker 1

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.