SQL Server Service Borker 1
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的更多相关文章
- The SQL Server Service Broker for the current database is not enabled
把一个数据恢复至另一个服务器上,出现了一个异常: The SQL Server Service Broker for the current database is not enabled, and ...
- SQL Server Service Broker创建单个数据库会话
概述 SQL Server Service Broker 用来创建用于交换消息的会话.消息在目标和发起方这两个端点之间进行交换.消息用于传输数据和触发消息收到时的处理过程.目标和发起方既可以在同一数据 ...
- SQL Server Service Broker创建单个数据库会话(消息队列)
概述 SQL Server Service Broker 用来创建用于交换消息的会话.消息在目标和发起方这两个端点之间进行交换.消息用于传输数据和触发消息收到时的处理过程.目标和发起方既可以在同一数据 ...
- 在Windows Server 2008 R2 Server中,连接其他服务器的数据库遇到“未启用当前数据库的 SQL Server Service Broker,因此查询通知不受支持。如果希望使用通知,请为此数据库启用 Service Broker ”
项目代码和数据库部署在不同的Windows Server 2008 R2 Server中,错误日志显示如下: "未启用当前数据库的 SQL Server Service Broker,因此查 ...
- SQL Server Service Broker(简称SSB)资料
SQL server Service Broker (下面简称SSB) 是SQL server 里面比较独特的一个功能.它可帮助开发人员构建异步的松散耦合应用程序.SSB的一些功能和好处包括有: 数据 ...
- SQL Server Service Broker 简单例子 (转)
SQL Server Service Broker服务体系结构 消息类型 — 定义应用程序间交换的消息的名称.还可以选择是否验证消息.约定 — 指定给定会话中的消息方向和消息类型.队列 — 存储消息. ...
- sql server Service Broker 相关查询
sql server Service Broker 相关查询 -- 查看传输队列中的消息 --如果尝试从队列中移除时,列将表明哪里出现了问题 select * from sys.transmissio ...
- Reusing dialogs with a dialog pool--一个sql server service broker例子
一个sql server service broker例子 ----------------------------------- USE master GO -------------------- ...
- SQL问题:未启用当前数据库的 SQL Server Service Broker
数据库分离后,附加回到数据库,然后在程序中打开调用数据库的页面,出现如下问题:“未启用当前数据库的 SQL Server Service Broker,因此查询通知不受支持.如果希望使用通知,请为此数 ...
随机推荐
- [转载] 高大上的 CSS 效果:Shape Blobbing
这篇大部分是转载,来自<高大上的 CSS 效果:Shape Blobbing>和 <Shape Blobbing in CSS> 有部分是自己理解和整理,配合效果要做出 app ...
- pragma comment的使用
该宏放置一个注释到对象文件或者可执行文件. #pragma comment( comment-type [,"commentstring"] ) comment-type是一个预定 ...
- HTTP 状态代码及其定义
所有 HTTP 状态代码及其定义. 代码 指示 2xx 成功 200 正常:请求已完成. 201 正常:紧接 POST 命令. 202 正常:已接受用于处理,但处理尚未完成. 20 ...
- CSS预处理器实践之Sass、Less比较
什么是CSS预处理器? CSS可以让你做很多事情,但它毕竟是给浏览器认的东西,对开发者来说,Css缺乏很多特性,例如变量.常量以及一些编程语法,代码难易组织和维护.这时Css预处理器就应运而生了.Cs ...
- jQuery粘性跟随滚动条滚动的导航栏源代码下载
jQuery粘性跟随滚动条滚动的导航栏源代码下载 作者:网页模板 大小:0.005MB 点击次数:3494 发布时间:2014-03-07 12:55 分享到:0 特效介绍 jQuery粘性跟随滚动条 ...
- Unity3d GUI弹窗
ArrayList w_position = new ArrayList(); void OnGUI() { if (GUILayout.Button("Open")) { if ...
- 【POJ】2318 TOYS ——计算几何+二分
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10281 Accepted: 4924 Description ...
- /var/cache/apt/archives/lock - open
问题: E: 无法获得锁 /var/cache/apt/archives/lock - open (11 资源临时不可用)E: 无法锁定下载目录o rm /var/cache/apt/archives ...
- #include <mutex>
多线程初级 #include <iostream> #include <thread> #include <windows.h> #include <mute ...
- 图片延迟加载技术-Lazyload的应用
我们在浏览图片量非常大的页面时,像淘宝商城商品展示.必应图片搜索这类网站,图片的加载非常流畅,其中就应用了图片延迟加载技术.本文讲解Lazyload图片加载插件,当我们打开页面时,首先在屏幕可视区域加 ...