/// <summary> /// Sends a packet to the queue /// </summary> /// <param name="packet">The packet to send</param> /// <param name="fromUri">The originating channel URI</param> public void SendMessage(OPSTelegrama packet, string fromUri) { BecsFecsHeader hd = new BecsFecsHeader("0", "0", fromUri, 0, 1, true); _outQueue.Send(hd, packet.XmlData); }
/// <summary> /// Handler for the inbound message queue ReceiveCompleted event /// </summary> /// <param name="header">The header of the incoming message</param> /// <param name="body">The body of the incoming message</param> public void OnQueueReceiveCompleted(BecsFecsHeader header, string body) { /// JLB 2004.07.21 - time sending a message /// Org.Mentalis.Utilities.StopWatch sw = new Org.Mentalis.Utilities.StopWatch(); IChannel channel = _channelMgr.GetChannel(header.Fid); long d = sw.Peek(); if (channel == null) { try { //>> LDRTEST0 //channel = _channelMgr.OpenChannel(header.Fid, ChannelType.FecsQueue); //<< LDRTEST0 } catch (Exception ex) { FecsMain.Logger.AddLog( string.Format("Couldn't open channel to send to {0}.", header.Fid), LoggerSeverities.Error); FecsMain.Logger.AddLog(ex); } if (channel != null) { SetupChannel(channel); } } if (channel != null) { if (d > 100) { FecsMain.Logger.AddLog(string.Format("Delay for GetChannel({1}) {0} ms", d, channel.Uri), LoggerSeverities.Debug); } try { OPSTelegrama t = OPSTelegramaFactory.CreateOPSTelegrama(Correlation.NextId, body); channel.SendMessage(t); FecsMain.Logger.AddLog( string.Format("Message sent to {0} [{1}].", channel.Uri, t.XmlData), LoggerSeverities.Info); } catch (Exception ex) { _channelMgr.CloseChannel(header.Fid); FecsMain.Logger.AddLog( string.Format("Couldn't send to {0}. Closing channel.", header.Fid), LoggerSeverities.Error); FecsMain.Logger.AddLog(ex); } } else { FecsMain.Logger.AddLog(string.Format("Delay for GetChannel({1}) {0} ms", d, header.Fid), LoggerSeverities.Debug); FecsMain.Logger.AddLog( string.Format("Message NOT sent to {0} [{1}].", header.Fid, body), LoggerSeverities.Error); } }