Rebus UseSqlServerInLeaseMode 已过时

问题描述 投票:0回答:1

在向我的应用程序添加 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
)

我真的不清楚应该如何使用这个新版本,新类中的大多数参数似乎都是只读的,到目前为止我尝试过的每个变体都无法编译。

有人有一个代码片段显示我如何删除这个过时的代码吗?

非常感谢!

c# rebus
1个回答
0
投票

技巧是在

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
);
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.