@@ -80,17 +80,17 @@ public async Task VerifyRabbitMQResource()
80
80
81
81
var connection = host . Services . GetRequiredService < IConnection > ( ) ;
82
82
83
- using var channel = connection . CreateModel ( ) ;
83
+ await using var channel = await connection . CreateChannelAsync ( ) ;
84
84
const string queueName = "hello" ;
85
- channel . QueueDeclare ( queueName , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
85
+ await channel . QueueDeclareAsync ( queueName , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
86
86
87
87
const string message = "Hello World!" ;
88
88
var body = Encoding . UTF8 . GetBytes ( message ) ;
89
89
90
- channel . BasicPublish ( exchange : string . Empty , routingKey : queueName , basicProperties : null , body : body ) ;
90
+ await channel . BasicPublishAsync ( exchange : string . Empty , routingKey : queueName , body : body ) ;
91
91
92
- var result = channel . BasicGet ( queueName , true ) ;
93
- Assert . Equal ( message , Encoding . UTF8 . GetString ( result . Body . Span ) ) ;
92
+ var result = await channel . BasicGetAsync ( queueName , true ) ;
93
+ Assert . Equal ( message , Encoding . UTF8 . GetString ( result ! . Body . Span ) ) ;
94
94
}
95
95
96
96
[ Theory ]
@@ -142,18 +142,19 @@ public async Task WithDataShouldPersistStateBetweenUsages(bool useVolume)
142
142
143
143
var connection = host . Services . GetRequiredService < IConnection > ( ) ;
144
144
145
- using var channel = connection . CreateModel ( ) ;
145
+ await using var channel = await connection . CreateChannelAsync ( ) ;
146
146
const string queueName = "hello" ;
147
- channel . QueueDeclare ( queueName , durable : true , exclusive : false ) ;
147
+ await channel . QueueDeclareAsync ( queueName , durable : true , exclusive : false ) ;
148
148
149
149
const string message = "Hello World!" ;
150
150
var body = Encoding . UTF8 . GetBytes ( message ) ;
151
151
152
- var props = channel . CreateBasicProperties ( ) ;
152
+ var props = new BasicProperties ( ) ;
153
153
props . Persistent = true ; // or props.DeliveryMode = 2;
154
- channel . BasicPublish (
154
+ await channel . BasicPublishAsync (
155
155
exchange : string . Empty ,
156
156
queueName ,
157
+ mandatory : true ,
157
158
props ,
158
159
body ) ;
159
160
}
@@ -199,12 +200,12 @@ public async Task WithDataShouldPersistStateBetweenUsages(bool useVolume)
199
200
200
201
var connection = host . Services . GetRequiredService < IConnection > ( ) ;
201
202
202
- using var channel = connection . CreateModel ( ) ;
203
+ await using var channel = await connection . CreateChannelAsync ( ) ;
203
204
const string queueName = "hello" ;
204
- channel . QueueDeclare ( queueName , durable : true , exclusive : false ) ;
205
+ await channel . QueueDeclareAsync ( queueName , durable : true , exclusive : false ) ;
205
206
206
- var result = channel . BasicGet ( queueName , true ) ;
207
- Assert . Equal ( "Hello World!" , Encoding . UTF8 . GetString ( result . Body . Span ) ) ;
207
+ var result = await channel . BasicGetAsync ( queueName , true ) ;
208
+ Assert . Equal ( "Hello World!" , Encoding . UTF8 . GetString ( result ! . Body . Span ) ) ;
208
209
}
209
210
}
210
211
finally
0 commit comments