private void WorkToDo() { var compressor = new Lz4(); while (!_isCanceled) { byte[] jsonBytes = new byte[0]; byte[] compressedBytes = new byte[0]; long alertListCount = 0; long eventListCount = 0; try { var alerts = ConsumeInSmallBatch(); // return to the while if there is nothing to save if (alerts.Item1.Count == 0) { continue; } //debug messaging incase anything goes wrong here. alertListCount = alerts.Item1.Count; eventListCount = alerts.Item1.Sum(x => x.Events.Length); string json = JsonConvert.SerializeObject(alerts.Item1); jsonBytes = Encoding.Unicode.GetBytes(json); compressedBytes = compressor.Compress(jsonBytes); _proxy.Produce(compressedBytes); } catch (Exception ex) { _exLog.Error($"alertListCount: {alertListCount} "); _exLog.Error($"eventListCount: {eventListCount} "); _exLog.Error($"jsonBytes: {jsonBytes.Length} "); _exLog.Error($"compressedBytes: {compressedBytes.Length} "); _exLog.Error(ex); } } }
public bool Produce(byte[] compressedJsonAlerts) { return(_proxy.InvokeRemoteAction(() => _service.Produce(compressedJsonAlerts))); }