c# – 队列动作处理的模式
发布时间:2020-12-15 21:54:04 所属栏目:百科 来源:网络整理
导读:我有一个包含排队元素的表,用于与另一个系统的同步问题 TableName | PrimaryKey | Action --------------------------------Products 15 DeleteProducts 21 Create Categories 9 Update TableName:目标SQL表的名称 PrimaryKey:相应表中目标元素的PK值 操作
我有一个包含排队元素的表,用于与另一个系统的同步问题
TableName | PrimaryKey | Action -------------------------------- Products 15 Delete Products 21 Create Categories 9 Update TableName:目标SQL表的名称 PrimaryKey:相应表中目标元素的PK值 操作:要执行的操作(示例:如果创建 – >推送创建远程系统中本地表产品的ID号为21的元素) 我需要的是一种在C#中正确处理这个问题的方法.我正在考虑使用命令模式. (ASP.Net MVC4 / C#) 你对这类问题有什么指导吗? 解决方法
您可以使用
that article中的建议和服务器端的进程队列.然后你的代码看起来像
create table TQueue (TableName nvarchar(128),PrimaryKey int,Action nvarchar(128)) create procedure sp_TQueue_Pop as begin declare @TableName nvarchar(128),@PrimaryKey int,@Action nvarchar(128) declare @temp_pop table (TableName nvarchar(128),Action nvarchar(128)) begin transaction select @TableName = null,@PrimaryKey = null,@Action = null delete top (1) from TQueue with (rowlock,readpast) output deleted.* into @temp_pop select @TableName = TableName,@PrimaryKey = PrimaryKey,@Action = Action from @temp_pop --================================================ -- do your processing here --================================================ select @TableName,@PrimaryKey,@Action end 出列你刚刚执行程序. 希望有所帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |