为什么我需要两个 SQL Server Service Broker 队列来完成一个简单的任务? [英] Why do I need two SQL Server Service Broker queues for a simple task?

查看:28
本文介绍了为什么我需要两个 SQL Server Service Broker 队列来完成一个简单的任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上找到的所有使用 SQL Server Service Broker 队列的示例似乎都有两个队列.我不明白为什么,每个例子似乎都假设这是显而易见的,没有必要解释.

All examples I find on the web for using SQL Server Service Broker queues seem to have two queues. I don't understand why and every example seems to assume that this is so obvious as to be unnecessary to explain.

一些东西将写入我的队列,一个存储过程将从它读取并插入到数据库中.为什么我需要两个队列?

Several things will write to my queue and a stored procedure will read from it and insert to database. Why do I need two queues?

例如:http://www.techrepublic.com/article/use-service-broker-internal-activation-in-sql-server-2005/6156264#

推荐答案

从技术上讲,您可以在应用程序中使用一个使用 SSB 技术的队列.在这种情况下,这个队列有来自发起者的请求消息和来自目标的响应消息的混乱.您的存储过程应该实现机制来区分彼此,整理它们,决定哪个响应针对哪个请求等等.还要记住,从这个队列接收消息的顺序是准确的,你不能跳过其中的一些并留在队列中以供进一步处理.

Technically you can use one queue using SSB technology in your application. In this case this queue has a mess from request messages from initiator and response messages from target. Your stored procedure should implement mechanism to distinguish one from another, sort out them, decide which response is for which request and so on. Also take in mind that RECEIVE messages from this queue in exact order and you can't skip some of them and leave in queue for further processing.

在您的情况下,最好遵循 Remus Rusanu 的回答并使用数据库表实现您的队列?

Maybe better in your case to follow Remus Rusanu's answer and implement your queue using database table?

SSB 的想法很简单 - 发起者将请求消息放入 Target 的队列,同时在其自己的队列中等待来自 Target 的响应消息.是你的情况吗?如果不是,也许您根本不需要 SSB?

SSB idea is simple - Initiator places request message into Target's queue while waiting response message from Target in its own queue. Is it your case? If no, maybe you need not SSB at all?

这篇关于为什么我需要两个 SQL Server Service Broker 队列来完成一个简单的任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆