Storage.MongoDb - dotnet-shashlik/shashlik.eventbus GitHub Wiki
Nuget: Shashlik.EventBus.MongoDb
。
/// <summary>
/// 使用连接字符串初始化注册MongoDb存储
/// </summary>
/// <param name="eventBusBuilder"></param>
/// <param name="connectionString">连接字符串</param>
/// <param name="publishTableName">已发布数据表名,默认值eventbus_published</param>
/// <param name="receiveTableName">已接收数据表名,默认值eventbus_received</param>
/// <returns></returns>
public static IEventBusBuilder AddSqlServer(
this IEventBusBuilder eventBusBuilder,
string connectionString,
string? publishCollectionName = null,
string? receiveCollectionName = null);
/// <summary>
/// 使用配置节点注册MongoDb存储
/// </summary>
/// <param name="eventBusBuilder"></param>
/// <param name="configurationSection">配置节点</param>
/// <returns></returns>
public static IEventBusBuilder AddMongoDb(
this IEventBusBuilder eventBusBuilder,
IConfigurationSection configurationSection);
/// <summary>
/// 使用自定义配置注册sqlserver存储
/// </summary>
/// <param name="eventBusBuilder"></param>
/// <param name="optionsAction">自定义配置</param>
/// <typeparam name="TDbContext"></typeparam>
/// <returns></returns>
public static IEventBusBuilder AddMongoDb(this IEventBusBuilder eventBusBuilder,
Action<EventBusMongoDbOptions>? optionsAction = null);
-
PublishedCollectionName
:已发布消息集合名称,默认值eventbus_published
-
ReceivedCollectionName
:已接收消息集合名称,默认值eventbus_received
-
DataBase
:数据库名称,默认值eventbus
-
ConnectionString
:MongoDb数据库连接字符串,默认值mongodb://localhost
MongoDb
事务支持需要集群支持,其事务上下文获取方式有:
new MongoDbTransactionContext(clientSessionHandle)
clientSessionHandle.GetTransactionContext()