public async Task RunReplyAction(ushort channel, int classMethodId, AmqpError error) { #if DEBUG if (classMethodId != 0) { // Confirm reply var classId = classMethodId >> 16; var methodId = classMethodId & 0x0000FFFF; var matchesClass = (ClassId == classId); var matchesMethod = MethodId == (methodId - 1); if (!matchesClass || !matchesMethod) { Console.WriteLine("[channel " + channel + "] Command for " + ClassId + "|" + MethodId + " did not match reply " + classId + "|" + methodId); } } #endif if (this.ReplyAction != null) { await this.ReplyAction(channel, classMethodId, error); } else { if (error != null) { AmqpIOBase.SetException(Tcs, error, classMethodId); AmqpIOBase.SetException(TcsSlim, error, classMethodId); } else { if (Tcs != null) { Tcs.SetResult(true); } if (TcsSlim != null) { TcsSlim.SetCompleted(); } } } if (_recycler != null) { _recycler(this); } }
public async Task RunReplyAction(ushort channel, int classMethodId, AmqpError error) { AssertCanBeUsed(); #if DEBUG if (classMethodId != 0) { // Confirm reply var classId = classMethodId >> 16; var methodId = classMethodId & 0x0000FFFF; var matchesClass = (ClassId == classId); var matchesMethod = MethodId == (methodId - 1); if (!matchesClass || !matchesMethod) { if (LogAdapter.ExtendedLogEnabled) { LogAdapter.LogDebug("CommandToSend", "[channel " + channel + "] Command for " + ClassId + "|" + MethodId + " did not match reply " + classId + "|" + methodId); } } } #endif // Allows more commands to be sent. This contention is sadly required by the amqp/rabbitmq if (_whenReplyReceived != null) { _whenReplyReceived.Set(); } // --- if (this.ReplyAction != null) { try { await this.ReplyAction(channel, classMethodId, error).ConfigureAwait(false); } catch (Exception ex) { error = new AmqpError { ReplyText = ex.Message }; AmqpIOBase.SetException(Tcs, error, classMethodId); AmqpIOBase.SetException(TcsSlim, error, classMethodId); throw; } } else { if (error != null) { AmqpIOBase.SetException(Tcs, error, classMethodId); AmqpIOBase.SetException(TcsSlim, error, classMethodId); } else { if (Tcs != null) { Tcs.SetResult(true); } if (TcsSlim != null) { TcsSlim.SetCompleted(); } } } if (_recycler != null) { _recycler(this); } }