1010 /// </summary>
1111 public static partial class RabbitMQTransportSettingsExtensions
1212 {
13+ /// <summary>
14+ /// Registers a custom routing topology.
15+ /// </summary>
16+ /// <param name="transportExtensions"></param>
17+ /// <param name="topologyFactory">The function used to create the routing topology instance. The parameter of the function indicates whether exchanges and queues declared by the routing topology should be durable.</param>
18+ public static TransportExtensions < RabbitMQTransport > UseRoutingTopology ( this TransportExtensions < RabbitMQTransport > transportExtensions , Func < bool , IRoutingTopology > topologyFactory )
19+ {
20+ transportExtensions . GetSettings ( ) . Set < Func < bool , IRoutingTopology > > ( topologyFactory ) ;
21+ return transportExtensions ;
22+ }
23+
1324 /// <summary>
1425 /// Uses the direct routing topology with the specified conventions.
1526 /// </summary>
@@ -28,17 +39,18 @@ public static TransportExtensions<RabbitMQTransport> UseDirectRoutingTopology(th
2839 exchangeNameConvention = ( address , eventType ) => "amq.topic" ;
2940 }
3041
31- transportExtensions . GetSettings ( ) . Set < DirectRoutingTopology . Conventions > ( new DirectRoutingTopology . Conventions ( exchangeNameConvention , routingKeyConvention ) ) ;
42+ transportExtensions . UseRoutingTopology ( durable => new DirectRoutingTopology ( new DirectRoutingTopology . Conventions ( exchangeNameConvention , routingKeyConvention ) , durable ) ) ;
3243
3344 return transportExtensions ;
3445 }
3546
3647 /// <summary>
3748 /// Registers a custom routing topology.
3849 /// </summary>
50+ [ ObsoleteEx ( RemoveInVersion = "6.0" , TreatAsErrorFromVersion = "5.0" , ReplacementTypeOrMember = "RabbitMQTransportSettingsExtensions.UseRoutingTopology(TransportExtensions<RabbitMQTransport> transportExtensions, Func<bool, IRoutingTopology>)" ) ]
3951 public static TransportExtensions < RabbitMQTransport > UseRoutingTopology < T > ( this TransportExtensions < RabbitMQTransport > transportExtensions ) where T : IRoutingTopology , new ( )
4052 {
41- transportExtensions . GetSettings ( ) . Set < IRoutingTopology > ( new T ( ) ) ;
53+ transportExtensions . UseRoutingTopology ( durable => new T ( ) ) ;
4254 return transportExtensions ;
4355 }
4456
0 commit comments