30
30
//---------------------------------------------------------------------------
31
31
32
32
using System ;
33
+ using System . Buffers ;
33
34
using System . Collections . Generic ;
34
35
using System . Diagnostics ;
35
36
using System . IO ;
@@ -507,7 +508,7 @@ protected void ChannelSend<TMethod, THeader>(in TMethod method, in THeader heade
507
508
}
508
509
509
510
[ 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 )
511
512
where TMethod : struct , IOutgoingAmqpMethod
512
513
where THeader : IAmqpHeader
513
514
{
@@ -516,7 +517,7 @@ protected ValueTask ModelSendAsync<TMethod, THeader>(in TMethod method, in THead
516
517
_flowControlBlock . Wait ( ) ;
517
518
}
518
519
519
- return Session . TransmitAsync ( in method , in header , body ) ;
520
+ return Session . TransmitAsync ( in method , in header , body , copyBody ) ;
520
521
}
521
522
522
523
internal void OnCallbackException ( CallbackExceptionEventArgs args )
@@ -1258,7 +1259,7 @@ public void BasicPublish<TProperties>(CachedString exchange, CachedString routin
1258
1259
ChannelSend ( in cmd , in basicProperties , body ) ;
1259
1260
}
1260
1261
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 )
1262
1263
where TProperties : IReadOnlyBasicProperties , IAmqpHeader
1263
1264
{
1264
1265
if ( NextPublishSeqNo > 0 )
@@ -1270,10 +1271,16 @@ public ValueTask BasicPublishAsync<TProperties>(string exchange, string routingK
1270
1271
}
1271
1272
1272
1273
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 ) ;
1274
1275
}
1275
1276
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 )
1277
1284
where TProperties : IReadOnlyBasicProperties , IAmqpHeader
1278
1285
{
1279
1286
if ( NextPublishSeqNo > 0 )
@@ -1285,7 +1292,13 @@ public ValueTask BasicPublishAsync<TProperties>(CachedString exchange, CachedStr
1285
1292
}
1286
1293
1287
1294
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 ) ;
1289
1302
}
1290
1303
1291
1304
public void UpdateSecret ( string newSecret , string reason )
0 commit comments