public void Write(IpcEvent ipcEvent) { logger.Warn("NullIpcEventWriter: No operation for Write"); }
void iEventWriter.Write(IpcEvent ipcEvent) { throw new NotImplementedException(); }
/// <summary> /// Writes an event by enqueueing in MmfWriter. /// </summary> /// <param name="ipcEvent">IpcEvent message to write</param> public void Write(IpcEvent ipcEvent) { try { //attempt lock bool tryLock = lockSection.WaitOne(60000); if (!tryLock) throw new TimeoutException("[IpcEventWriter " + _ipcType + "] Could not obtain lock while writing event"); try { if (!started) throw new Exception("[IpcEventWriter " + _ipcType + "] Cannot write event " + ipcEvent.SerialID + ": IpcEventWriter is not started."); //get next serial ID id = Niawa.Utilities.IdGeneratorUtils.IncrementSerialId(id); ipcEvent.SerialID = id.ToString(); //create MMF message Niawa.IpcController.NiawaMmfContainer msg = new Niawa.IpcController.NiawaMmfContainer(System.DateTime.Now, _ipcType, ipcEvent.ToJson()); //, ipcEvent.EventID.ToString()); logger.Debug("[IpcEventWriter " + _ipcType + "] Writing IPC Event " + ipcEvent.SerialID + ""); //write MMF message mmfWriter.WriteData(msg); } finally { //release lock lockSection.Release(); } } catch (Exception ex) { logger.Error("[IpcEventWriter " + _ipcType + "] Caught exception during IpcEventWriter Write [" + ipcEvent.SerialID + "]: " + ex.Message, ex); if (_ignoreIpcExceptions) { } else throw ex; } }