3030//---------------------------------------------------------------------------
3131
3232using System ;
33+ using System . Buffers ;
3334using System . Collections . Generic ;
3435using System . Diagnostics ;
3536using System . IO ;
@@ -507,7 +508,7 @@ protected void ChannelSend<TMethod, THeader>(in TMethod method, in THeader heade
507508 }
508509
509510 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
510- protected ValueTask ModelSendAsync < TMethod , THeader > ( in TMethod method , in THeader header , ReadOnlyMemory < byte > body )
511+ protected ValueTask ModelSendAsync < TMethod , THeader > ( in TMethod method , in THeader header , ReadOnlySequence < byte > body , bool copyBody )
511512 where TMethod : struct , IOutgoingAmqpMethod
512513 where THeader : IAmqpHeader
513514 {
@@ -516,7 +517,7 @@ protected ValueTask ModelSendAsync<TMethod, THeader>(in TMethod method, in THead
516517 _flowControlBlock . Wait ( ) ;
517518 }
518519
519- return Session . TransmitAsync ( in method , in header , body ) ;
520+ return Session . TransmitAsync ( in method , in header , body , copyBody ) ;
520521 }
521522
522523 internal void OnCallbackException ( CallbackExceptionEventArgs args )
@@ -1258,7 +1259,7 @@ public void BasicPublish<TProperties>(CachedString exchange, CachedString routin
12581259 ChannelSend ( in cmd , in basicProperties , body ) ;
12591260 }
12601261
1261- public ValueTask BasicPublishAsync < TProperties > ( string exchange , string routingKey , in TProperties basicProperties , ReadOnlyMemory < byte > body , bool mandatory )
1262+ public ValueTask BasicPublishAsync < TProperties > ( string exchange , string routingKey , in TProperties basicProperties , ReadOnlySequence < byte > body , bool mandatory , bool copyBody = true )
12621263 where TProperties : IReadOnlyBasicProperties , IAmqpHeader
12631264 {
12641265 if ( NextPublishSeqNo > 0 )
@@ -1270,10 +1271,16 @@ public ValueTask BasicPublishAsync<TProperties>(string exchange, string routingK
12701271 }
12711272
12721273 var cmd = new BasicPublish ( exchange , routingKey , mandatory , default ) ;
1273- return ModelSendAsync ( in cmd , in basicProperties , body ) ;
1274+ return ModelSendAsync ( in cmd , in basicProperties , body , copyBody ) ;
12741275 }
12751276
1276- public ValueTask BasicPublishAsync < TProperties > ( CachedString exchange , CachedString routingKey , in TProperties basicProperties , ReadOnlyMemory < byte > body , bool mandatory )
1277+ public ValueTask BasicPublishAsync < TProperties > ( string exchange , string routingKey , in TProperties basicProperties , ReadOnlyMemory < byte > body , bool mandatory , bool copyBody = true )
1278+ where TProperties : IReadOnlyBasicProperties , IAmqpHeader
1279+ {
1280+ return BasicPublishAsync ( exchange , routingKey , in basicProperties , new ReadOnlySequence < byte > ( body ) , mandatory , copyBody ) ;
1281+ }
1282+
1283+ public ValueTask BasicPublishAsync < TProperties > ( CachedString exchange , CachedString routingKey , in TProperties basicProperties , ReadOnlySequence < byte > body , bool mandatory , bool copyBody = true )
12771284 where TProperties : IReadOnlyBasicProperties , IAmqpHeader
12781285 {
12791286 if ( NextPublishSeqNo > 0 )
@@ -1285,7 +1292,13 @@ public ValueTask BasicPublishAsync<TProperties>(CachedString exchange, CachedStr
12851292 }
12861293
12871294 var cmd = new BasicPublishMemory ( exchange . Bytes , routingKey . Bytes , mandatory , default ) ;
1288- return ModelSendAsync ( in cmd , in basicProperties , body ) ;
1295+ return ModelSendAsync ( in cmd , in basicProperties , body , copyBody ) ;
1296+ }
1297+
1298+ public ValueTask BasicPublishAsync < TProperties > ( CachedString exchange , CachedString routingKey , in TProperties basicProperties , ReadOnlyMemory < byte > body , bool mandatory , bool copyBody = true )
1299+ where TProperties : IReadOnlyBasicProperties , IAmqpHeader
1300+ {
1301+ return BasicPublishAsync ( exchange , routingKey , in basicProperties , new ReadOnlySequence < byte > ( body ) , mandatory , copyBody ) ;
12891302 }
12901303
12911304 public void UpdateSecret ( string newSecret , string reason )
0 commit comments