ssbconversationmediator.cs
来自「SQL Server 2005 Service Broker (SSB) is 」· CS 代码 · 共 64 行
CS
64 行
using System;
using System.Collections.Generic;
using System.Text;
using System.Transactions;
namespace SSBExternalActivationRouter
{
class SSBConversationMediator
{
ITransactedMessageMediator _mediator;
ServiceMessageMapperSignal _signal;
SSBConversation _conv = new SSBConversation();
public SSBConversationMediator(ITransactedMessageMediator med, ServiceMessageMapperSignal signal)
{
_mediator = med;
_signal = signal;
}
public void OpenChannels(string source, object destination)
{
_conv.Init(source);
_mediator.Init(destination);
}
public void Process()
{
TransactionScope ReadMsgScope;
while (IsConversationToProcess() && _signal.ContinueProcessing)
{
ReadMsgScope = new TransactionScope();
//Begin transaction
using (ReadMsgScope)
{
_conv.ReadMessage();
if (_conv.IsTermMessage())
{
//Do nothing commit tran and move on
}
else
{
_mediator.Translate(_conv.CurrentMessage);
}
//Commits the changes
ReadMsgScope.Complete();
}
}
}
public bool IsConversationToProcess()
{
return (_conv.AreThereMessages());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?