示例#1
0
            ///<summary>
            ///  return true means the transaction has been flushed.
            ///</summary>
            ///<param name="manager"> </param>
            ///<param name="transaction"> </param>
            ///<returns> true if message is flushed, false otherwise </returns>
            public bool End(DefaultMessageManager manager, ITransaction transaction)
            {
                if (_mStack.Count != 0)
                {
                    ITransaction current = _mStack.Pop();
                    while (transaction != current && _mStack.Count != 0)
                    {
                        current = _mStack.Pop();
                    }
                    if (transaction != current)
                        throw new Exception("没找到对应的Transaction.");

                    if (_mStack.Count == 0)
                    {
                        ValidateTransaction(current);

                        IMessageTree tree = _mTree.Copy();
                        _mTree.MessageId = null;
                        _mTree.Message = null;
                        manager.Flush(tree);
                        return true;
                    }
                    return false;
                }

                throw new Exception("Stack为空, 没找到对应的Transaction.");
            }
示例#2
0
 /// <summary>
 ///   添加Event和Heartbeat
 /// </summary>
 /// <param name="manager"> </param>
 /// <param name="message"> </param>
 public void Add(DefaultMessageManager manager, IMessage message)
 {
     if ((_mStack.Count == 0))
     {
         IMessageTree tree = _mTree.Copy();
         tree.MessageId = manager.NextMessageId();
         tree.Message = message;
         manager.Flush(tree);
     }
     else
     {
         ITransaction entry = _mStack.Peek();
         entry.AddChild(message);
     }
 }
示例#3
0
            /// <summary>
            ///   添加transaction
            /// </summary>
            /// <param name="manager"> </param>
            /// <param name="transaction"> </param>
            public void Start(DefaultMessageManager manager, ITransaction transaction)
            {
                if (_mStack.Count != 0)
                {
                    transaction.Standalone = false;
                    ITransaction entry = _mStack.Peek();
                    entry.AddChild(transaction);
                }
                else
                {
                    _mTree.MessageId = manager.NextMessageId();
                    _mTree.Message = transaction;
                }

                _mStack.Push(transaction);
            }
示例#4
0
文件: Cat.cs 项目: peterluo0822/wcf-1
        public static void Initialize(string configFile)
        {
            if (Instance._mInitialized)
            {
                Logger.Warn("Cat can't initialize again with config file({0}), IGNORED!", configFile);
                return;
            }

            Logger.Info("Initializing Cat .Net Client ...");

            DefaultMessageManager manager = new DefaultMessageManager();
            ClientConfig clientConfig = LoadClientConfig(configFile);

            manager.InitializeClient(clientConfig);
            Instance._mProducer = new DefaultMessageProducer(manager);
            Instance._mManager = manager;
            Instance._mInitialized = true;

            Logger.Info("Cat .Net Client initialized.");
        }
            /// <summary>
            ///   添加transaction
            /// </summary>
            /// <param name="manager"> </param>
            /// <param name="transaction"> </param>
            public void Start(DefaultMessageManager manager, ITransaction transaction)
            {
                if (_mStack.Count != 0)
                {
                    transaction.Standalone = false;
                    ITransaction entry = _mStack.Peek();
                    entry.AddChild(transaction);
                }
                else
                {
                    _mTree.MessageId = manager.NextMessageId();
                    _mTree.Message = transaction;
                }

                _mStack.Push(transaction);
            }
            ///<summary>
            ///  return true means the transaction has been flushed.
            ///</summary>
            ///<param name="manager"> </param>
            ///<param name="transaction"> </param>
            ///<returns> true if message is flushed, false otherwise </returns>
            public bool End(DefaultMessageManager manager, ITransaction transaction)
            {
                if (_mStack.Count != 0)
                {
                    ITransaction current = _mStack.Pop();
                    while (transaction != current && _mStack.Count != 0)
                    {
                        current = _mStack.Pop();
                    }
                    if (transaction != current)
                        throw new Exception("没找到对应的Transaction.");

                    if (_mStack.Count == 0)
                    {
                        ValidateTransaction(current);

                        IMessageTree tree = _mTree.Copy();
                        _mTree.MessageId = null;
                        _mTree.Message = null;
                        manager.Flush(tree);
                        return true;
                    }
                    return false;
                }

                throw new Exception("Stack为空, 没找到对应的Transaction.");
            }
 /// <summary>
 ///   添加Event和Heartbeat
 /// </summary>
 /// <param name="manager"> </param>
 /// <param name="message"> </param>
 public void Add(DefaultMessageManager manager, IMessage message)
 {
     if ((_mStack.Count == 0))
     {
         IMessageTree tree = _mTree.Copy();
         tree.MessageId = manager.NextMessageId();
         tree.Message = message;
         manager.Flush(tree);
     }
     else
     {
         ITransaction entry = _mStack.Peek();
         entry.AddChild(message);
     }
 }