/// <summary>
        /// transmmit message sycronously
        /// </summary>
        /// <param name="StrMessage"></param>
        /// <returns></returns>
        public int SendMessage(string StrMessage)
        {
            ISender _RawSender = null;

            try
            {
                int iResponse = -1;
                Logger.Debug("EventTransmitter", "SendMessage", StrMessage);
                //Getting mode of transfer
                _RawSender = SenderFactory.GetSender();
                Logger.Debug("EventTransmitter", "SendMessage", "Initiate Sender");
                _RawSender.Initialize(Settings.STMServerIP, 0);
                Logger.Debug("EventTransmitter", "SendMessage", "Send Data");
                iResponse = _RawSender.Send(FormatFactory.GetFormatter(StrMessage, false));
                Logger.Debug("EventTransmitter", "SendMessage", "STM Response:" + iResponse.ToString());
                return(iResponse);
            }
            catch (Exception Ex)
            {
                Logger.Error("EventTransmitter", "SendMessage", Ex.Message);
                throw Ex;
            }
            finally
            {
                _RawSender.CloseSender();
            }
        }
        /// <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);
                                    Logger.Debug("Response from Server: " + iResponse.ToString());
                                    if (iResponse > 0)    // to be checked && msg.SequenceNo == bSequenceNo)// ACK
                                    {
                                        //Set retry value to MAX+1 to quit loop
                                        iRetryOnNWErr = Settings.iMaxTransmissionRetry + 1;
                                        //Commiting Queue read After succesfull Transaction
                                        Logger.Info("Committing Queue");
                                        _Message.Commit();
                                    }

                                    else if (iResponse == 0)
                                    {
                                        Logger.Info("Response from Server [0] Message not processed at server");
                                        //Set retry value to MAX+1 to quit loop
                                        iRetryOnNWErr = Settings.iMaxTransmissionRetry + 1;
                                        //Commiting Queue read After succesfull Transaction
                                        Logger.Info("Committing Queue");
                                        _Message.Commit();
                                    }
                                    else
                                    {
                                        if (Settings.EventTransmit_RetryRepeat == 0)
                                        {
                                            iRetryOnNWErr++;
                                            Logger.Info(string.Format("Retrying to send message (Attempt[{0}]) ", iRetryOnNWErr.ToString()));
                                        }
                                        else
                                        {
                                            Logger.Info("Retrying to send message");
                                            iRetryOnNWErr = 0;
                                        }
                                    }
                                }
                            }
                            catch (Exception Ex1)
                            {
                                _evtTransmitShutDown.WaitOne(5000);
                                Logger.Error("EventTransmitter", "Transmit", Ex1);
                                //refresh connection and retry till configured number of times
                                iRetryOnNWErr++;
                                _Sender.CloseSender();
                                _IsTransmitting = false;
                                _Sender.Initialize(Settings.STMServerIP, Settings.STMServerPort);
                            }
                        } while (iRetryOnNWErr <= Settings.iMaxTransmissionRetry);
                    }
                }
            }
            catch (Exception Ex)
            {
                Logger.Error("EventTransmitter", "Transmit", Ex.Message);
                if (Settings.EventTransmit_RecoverOnError != 0)
                {
                    _evtTransmitShutDown.WaitOne(2000);
                    this.Transmit();
                }
            }
            finally
            {
                this.CloseTransmission();
            }
        }