private async Task HandleMessageWithContent(IMessage <T> message) { try { Log.Debug($"Processing message of type {typeof(T).FullName}", message.Content.ToDictionary()); try { _messageContextProvider.StoreMessageContext(message); await ProcessMessage(message.Content); } finally { _messageContextProvider.ReleaseMessageContext(message); } await message.CompleteAsync(); Log.Info($"Completed message {typeof(T).FullName}"); } catch (Exception ex) { Log.Error(ex, $"Failed to process message {typeof(T).FullName}"); if (message?.Content != null) { await message.AbortAsync(); } await OnErrorAsync(message, ex); } }
private async Task <bool> IsNoMessageContent(IMessage <T> message) { if (message.Content == null) { Interlocked.Increment(ref _nullMessageContentCount); Log.Debug($"Message {message.Id} of type {typeof(T).FullName} has null content - ignoring message"); await message.CompleteAsync(); return(true); } return(false); }