internal void WriteRaw(RedisMessage message) { if (message.Db >= 0) { throw new ArgumentException("message", "WriteRaw cannot be used with db-centric messages"); } RecordSent(message); message.Write(outBuffer); Interlocked.Increment(ref messagesSent); }
private void Outgoing() { try { OnOpened(); int db = 0; RedisMessage next; Trace.WriteLine("Redis send-pump is starting"); bool isHigh, shouldFlush; while (unsent.TryDequeue(false, out next, out isHigh, out shouldFlush)) { if (abort) { CompleteMessage(next, RedisResult.Error("The system aborted before this message was sent")); continue; } if (!next.ChangeState(MessageState.NotSent, MessageState.Sent)) { // already cancelled; not our problem any more... Interlocked.Increment(ref messagesCancelled); continue; } if (isHigh) { Interlocked.Increment(ref queueJumpers); } WriteMessage(ref db, next, null); Flush(shouldFlush); } Interlocked.CompareExchange(ref state, (int)ConnectionState.Closing, (int)ConnectionState.Open); if (redisStream != null) { RedisMessage quit = RedisMessage.Create(-1, RedisLiteral.QUIT).ExpectOk().Critical(); RecordSent(quit, !abort); quit.Write(outBuffer); outBuffer.Flush(); redisStream.Flush(); Interlocked.Increment(ref messagesSent); } Trace.WriteLine("Redis send-pump is exiting"); } catch (Exception ex) { OnError("Outgoing queue", ex, true); } }
public override void Write(Stream stream) { innnerMessage.Write(stream); }