Skip to content

Commit

Permalink
Simplify code.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Oct 8, 2024
1 parent 6be3222 commit d7e618d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions projects/RabbitMQ.Client/Impl/ChannelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,9 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
_nextPublishSeqNo++;
}

await EnforceFlowControlAsync(cancellationToken)
.ConfigureAwait(false);

var cmd = new BasicPublish(exchange, routingKey, mandatory, default);

using Activity? sendActivity = RabbitMQActivitySource.PublisherHasListeners
Expand All @@ -1032,15 +1035,11 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
BasicProperties? props = PopulateBasicPropertiesHeaders(basicProperties, sendActivity, publishSequenceNumber);
if (props is null)
{
await EnforceFlowControlAsync(cancellationToken)
.ConfigureAwait(false);
await ModelSendAsync(in cmd, in basicProperties, body, cancellationToken)
.ConfigureAwait(false);
}
else
{
await EnforceFlowControlAsync(cancellationToken)
.ConfigureAwait(false);
await ModelSendAsync(in cmd, in props, body, cancellationToken)
.ConfigureAwait(false);
}
Expand Down Expand Up @@ -1105,23 +1104,23 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
_nextPublishSeqNo++;
}

await EnforceFlowControlAsync(cancellationToken)
.ConfigureAwait(false);

var cmd = new BasicPublishMemory(exchange.Bytes, routingKey.Bytes, mandatory, default);

using Activity? sendActivity = RabbitMQActivitySource.PublisherHasListeners
? RabbitMQActivitySource.Send(routingKey.Value, exchange.Value, body.Length)
: default;

BasicProperties? props = PopulateBasicPropertiesHeaders(basicProperties, sendActivity, publishSequenceNumber);
if (props is null)
{
await EnforceFlowControlAsync(cancellationToken)
.ConfigureAwait(false);
await ModelSendAsync(in cmd, in basicProperties, body, cancellationToken)
.ConfigureAwait(false);
}
else
{
await EnforceFlowControlAsync(cancellationToken)
.ConfigureAwait(false);
await ModelSendAsync(in cmd, in props, body, cancellationToken)
.ConfigureAwait(false);
}
Expand Down

0 comments on commit d7e618d

Please sign in to comment.