Skip to content

Commit

Permalink
fix: consumer was checking for null, but EnsureChannel creates later
Browse files Browse the repository at this point in the history
  • Loading branch information
iancooper committed Feb 5, 2025
1 parent 0c013e8 commit bf09c19
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ public void Reject(Message message)
/// <returns>Message.</returns>
public Message[] Receive(TimeSpan? timeOut = null)
{
if (_consumer is null)
throw new InvalidOperationException("RmqMessageConsumer.Receive - value of _consumer cannot be null");


if (Connection.Exchange is null)
throw new InvalidOperationException("RmqMessageConsumer.Receive - value of Connection.Exchange cannot be null");

Expand All @@ -290,7 +288,8 @@ public Message[] Receive(TimeSpan? timeOut = null)
{
EnsureChannel();

var (resultCount, results) = _consumer.DeQueue(timeOut.Value, _batchSize);
//NOTE: EnsureChannel means that _consumer cannot be null
var (resultCount, results) = _consumer!.DeQueue(timeOut.Value, _batchSize);

if (results != null && results.Length != 0)
{
Expand Down

0 comments on commit bf09c19

Please sign in to comment.