/// <summary> /// Receives the next transport message or null if none is available. Can block if it wants to, just respect the <paramref name="cancellationToken"/> /// </summary> public override async Task<TransportMessage> Receive(ITransactionContext context, CancellationToken cancellationToken) { if (amqpReceiver == null) return null; AmqpLite.Message msg = await amqpReceiver.ReceiveAsync(TimeSpan.FromSeconds(0.5)); if (msg == null) return null; if (!(msg.Properties?.AbsoluteExpiryTime != DateTime.MinValue && msg.Properties?.AbsoluteExpiryTime.ToUniversalTime() > DateTime.Now.ToUniversalTime())) return null; context.OnCompleted(async ctx => { amqpReceiver.Accept(msg); }); context.OnAborted(async ctx => { amqpReceiver.Modify(msg, true); }); context.OnDisposed(async ctx => { //amqpReceiver.Close(); }); var result = new TransportMessage(GetHeaders(msg), GetBytes(msg.Body.ToString())); return result; }