@@ -188,5 +188,41 @@ await topologyManager.CreateQueueAsync(new QueueConfiguration
188188 Assert . Equal ( "foo3" , ( await consumer . ReceiveAsync ( CancellationToken ) ) . GetBody < string > ( ) ) ;
189189 Assert . Equal ( "foo6" , ( await consumer . ReceiveAsync ( CancellationToken ) ) . GetBody < string > ( ) ) ;
190190 }
191+
192+ [ Fact ]
193+ public async Task Should_create_non_destructive_queue ( )
194+ {
195+ var connection = await CreateConnection ( ) ;
196+ var address = Guid . NewGuid ( ) . ToString ( ) ;
197+ var queue = Guid . NewGuid ( ) . ToString ( ) ;
198+
199+ var topologyManager = await connection . CreateTopologyManagerAsync ( ) ;
200+ await topologyManager . CreateAddressAsync ( address , RoutingType . Multicast ) ;
201+ await topologyManager . CreateQueueAsync ( new QueueConfiguration
202+ {
203+ Address = address ,
204+ Name = queue ,
205+ RoutingType = RoutingType . Multicast ,
206+ NonDestructive = true
207+ } ) ;
208+
209+ var producer = await connection . CreateProducerAsync ( address , RoutingType . Multicast ) ;
210+
211+ await producer . SendAsync ( new Message ( "foo" ) ) ;
212+
213+ var consumer = await connection . CreateConsumerAsync ( address , queue , CancellationToken ) ;
214+ var msg = await consumer . ReceiveAsync ( CancellationToken ) ;
215+ await consumer . AcceptAsync ( msg ) ;
216+ Assert . Equal ( "foo" , msg . GetBody < string > ( ) ) ;
217+
218+ // close consumer
219+ await consumer . DisposeAsync ( ) ;
220+
221+ // recreate consumer, and the message should be redelivered as the queue was created as non-destructive
222+ consumer = await connection . CreateConsumerAsync ( address , queue , CancellationToken ) ;
223+ msg = await consumer . ReceiveAsync ( CancellationToken ) ;
224+ await consumer . AcceptAsync ( msg ) ;
225+ Assert . Equal ( "foo" , msg . GetBody < string > ( ) ) ;
226+ }
191227 }
192228}
0 commit comments