本文整理汇总了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);
//.........这里部分代码省略.........