在向我的应用程序添加 Rebus 服务时,我有一些代码使用过时版本的 UseSqlServerInLeaseMode。
过时的版本(如下)有几个参数,所有(除了最后一个)都在我的代码中使用。
public static void UseSqlServerInLeaseMode(
this StandardConfigurer<ITransport> configurer,
string connectionString,
string inputQueueName,
TimeSpan? leaseInterval = null,
TimeSpan? leaseTolerance = null,
bool automaticallyRenewLeases = false,
TimeSpan? leaseAutoRenewInterval = null,
Func<string> leasedByFactory = null,
bool enlistInAmbientTransaction = false,
bool ensureTablesAreCreated = true
)
我应该使用的推荐版本是:
public static SqlServerLeaseTransportOptions UseSqlServerInLeaseMode(
this StandardConfigurer<ITransport> configurer,
SqlServerLeaseTransportOptions transportOptions,
string inputQueueName
)
我真的不清楚应该如何使用这个新版本,新类中的大多数参数似乎都是只读的,到目前为止我尝试过的每个变体都无法编译。
有人有一个代码片段显示我如何删除这个过时的代码吗?
非常感谢!
技巧是在
Set...
中使用各种
SqlServerLeaseTransportOptions
函数
因此要从此转换:
x.UseSqlServerInLeaseMode(
connectionString,
inputQueueName,
leaseInterval,
leaseTolerance,
automaticallyRenewLeases,
leaseAutoRenewInterval,
leasedByFactory,
enlistInAmbientTransaction,
ensureTablesAreCreated,
)
它应该看起来像这样:
SqlServerLeaseTransportOptions transportOptions = new(connectionString, enlistInAmbientTransaction);
transportOptions.SetLeaseInterval(leaseInterval);
transportOptions.SetLeaseTolerance(leaseTolerance);
transportOptions.SetAutomaticLeaseRenewal(automaticallyRenewLeases, leaseAutoRenewInterval);
transportOptions.SetLeasedByFactory(leasedByFactory);
transportOptions.SetEnsureTablesAreCreated(ensureTablesAreCreated);
x.UseSqlServerInLeaseMode(
transportOptions,
inputQueueName
);