当前位置: 首页>>代码示例>>C#>>正文


C# ISender.Initialize方法代码示例

本文整理汇总了C#中ISender.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# ISender.Initialize方法的具体用法?C# ISender.Initialize怎么用?C# ISender.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISender的用法示例。


在下文中一共展示了ISender.Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transmit

        /// <summary>
        /// Transmit Messages from queue to Server
        /// </summary>
        void Transmit()
        {
            try
            {
                UInt32 iSequenceNo = 0;
                Byte bSequenceNo;
                Logger.Info("EventTransmitter: STARTING");
                _Message = new QueueManager(Settings.EventTransmitterSourceQ);
    
                //Getting mode of transfer
               _Sender = SenderFactory.GetSender();

                if (this.InitializeWithRetry())
                {
                    _Message.OpenQueue();

                    while (!_evtTransmitShutDown.WaitOne(10))
                    {

                        Int32 iResponse;
                            try
                            {
                                _IsTransmitting = true;

                                if (iSequenceNo >= 255)
                                {
                                    iSequenceNo = 1;
                                }
                                else
                                {
                                    iSequenceNo++;
                                }
                                bSequenceNo = Convert.ToByte(iSequenceNo);
                                Logger.Info("Reading queue");
                                
                                if (!_Message.IsQueueOpen)
                                {
                                    _Message.OpenQueue();
                                }

                                strXML = _Message.ReadMessage();
                                Logger.Info("Read Complete");
                                SendToExternalLog("SENDING: " + strXML);
                                // parse return message 
                                //Construct STM format message 

                                // Refresh or empty message
                                if (string.IsNullOrEmpty(strXML))
                                {
                                    Logger.Debug("Either Queue refresh or no message received.");
                                    continue;
                                }

                                _MessageFormatter = FormatFactory.GetFormatter(strXML, true);

                                Logger.Debug("Event Request SeqNo[" + iSequenceNo.ToString() + "]" + _MessageFormatter.MessageStream);
                            }
                            catch (MessageFilteredException MesEx)
                            {
                                Logger.Error("EventTransmitter", "Transmit", MesEx.Message);
                                Logger.Info("EventTransmitter", "Transmit", "Committing Queue[Filtered Message]");
                                _Message.Commit();
                                continue;
                            }
                            catch (Exception Ex)
                            {
                                Logger.Error("EventTransmitter", "Transmit", Ex);
                                Logger.Info("EventTransmitter", "Transmit", "Error in message:" + strXML);

                                if (Settings.DeleteMessageOnParseErr == 1)
                                {
                                    Logger.Error("EventTransmitter", "Transmit", "Committing Queue[DeleteMessageOnParseErr]");
                                    _Message.Commit();
                                    continue;
                                }
                                _evtTransmitShutDown.WaitOne(5000);
                            }
                            int iRetryOnNWErr = 0;
                            do
                            {
                                if (_evtTransmitShutDown.WaitOne(50))
                                {
                                    break;
                                }

                                try
                                {
                                    if (iRetryOnNWErr >= Settings.iMaxTransmissionRetry)
                                    {
                                        //Close transmission when maximum retry reached 
                                        throw new Exception(String.Format("Stopping Transmision after Retrying [{0}] times. ", iRetryOnNWErr.ToString()));
                                    }
                                    else
                                    {

                                        //transmit message to server 
                                        iResponse = _Sender.Send(_MessageFormatter);
//.........这里部分代码省略.........
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:101,代码来源:EventTransmitter.cs


注:本文中的ISender.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。