⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssbconversationmediator.cs

📁 SQL Server 2005 Service Broker (SSB) is an asynchronous messaging technology built into SQL Server.
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -