Skip to content

Commit d7e618d

Browse files
committed
Simplify code.
1 parent 6be3222 commit d7e618d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

projects/RabbitMQ.Client/Impl/ChannelBase.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,9 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
10231023
_nextPublishSeqNo++;
10241024
}
10251025

1026+
await EnforceFlowControlAsync(cancellationToken)
1027+
.ConfigureAwait(false);
1028+
10261029
var cmd = new BasicPublish(exchange, routingKey, mandatory, default);
10271030

10281031
using Activity? sendActivity = RabbitMQActivitySource.PublisherHasListeners
@@ -1032,15 +1035,11 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
10321035
BasicProperties? props = PopulateBasicPropertiesHeaders(basicProperties, sendActivity, publishSequenceNumber);
10331036
if (props is null)
10341037
{
1035-
await EnforceFlowControlAsync(cancellationToken)
1036-
.ConfigureAwait(false);
10371038
await ModelSendAsync(in cmd, in basicProperties, body, cancellationToken)
10381039
.ConfigureAwait(false);
10391040
}
10401041
else
10411042
{
1042-
await EnforceFlowControlAsync(cancellationToken)
1043-
.ConfigureAwait(false);
10441043
await ModelSendAsync(in cmd, in props, body, cancellationToken)
10451044
.ConfigureAwait(false);
10461045
}
@@ -1105,23 +1104,23 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
11051104
_nextPublishSeqNo++;
11061105
}
11071106

1107+
await EnforceFlowControlAsync(cancellationToken)
1108+
.ConfigureAwait(false);
1109+
11081110
var cmd = new BasicPublishMemory(exchange.Bytes, routingKey.Bytes, mandatory, default);
1111+
11091112
using Activity? sendActivity = RabbitMQActivitySource.PublisherHasListeners
11101113
? RabbitMQActivitySource.Send(routingKey.Value, exchange.Value, body.Length)
11111114
: default;
11121115

11131116
BasicProperties? props = PopulateBasicPropertiesHeaders(basicProperties, sendActivity, publishSequenceNumber);
11141117
if (props is null)
11151118
{
1116-
await EnforceFlowControlAsync(cancellationToken)
1117-
.ConfigureAwait(false);
11181119
await ModelSendAsync(in cmd, in basicProperties, body, cancellationToken)
11191120
.ConfigureAwait(false);
11201121
}
11211122
else
11221123
{
1123-
await EnforceFlowControlAsync(cancellationToken)
1124-
.ConfigureAwait(false);
11251124
await ModelSendAsync(in cmd, in props, body, cancellationToken)
11261125
.ConfigureAwait(false);
11271126
}

0 commit comments

Comments
 (0)