diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreInboxConfigExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreInboxConfigExtensions.cs index 9f0ff3f35b..4092de5b3b 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreInboxConfigExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreInboxConfigExtensions.cs @@ -1,3 +1,4 @@ +using Volo.Abp.Data; using Volo.Abp.EventBus.Distributed; namespace Volo.Abp.EntityFrameworkCore.DistributedEvents; @@ -8,5 +9,6 @@ public static class EfCoreInboxConfigExtensions where TDbContext : IHasEventInbox { outboxConfig.ImplementationType = typeof(IDbContextEventInbox); + outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName(); } } diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreOutboxConfigExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreOutboxConfigExtensions.cs index 2071a832e8..5da25e2d14 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreOutboxConfigExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreOutboxConfigExtensions.cs @@ -1,4 +1,5 @@ -using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Data; +using Volo.Abp.EventBus.Distributed; namespace Volo.Abp.EntityFrameworkCore.DistributedEvents; @@ -8,5 +9,6 @@ public static class EfCoreOutboxConfigExtensions where TDbContext : IHasEventOutbox { outboxConfig.ImplementationType = typeof(IDbContextEventOutbox); + outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName(); } } diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/InboxConfig.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/InboxConfig.cs index b2d90e707e..94e0e55be9 100644 --- a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/InboxConfig.cs +++ b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/InboxConfig.cs @@ -8,6 +8,13 @@ public class InboxConfig [NotNull] public string Name { get; } + [NotNull] + public string DatabaseName { + get => _databaseName; + set => _databaseName = Check.NotNullOrWhiteSpace(value, nameof(DatabaseName)); + } + [NotNull] private string _databaseName; + public Type ImplementationType { get; set; } public Func EventSelector { get; set; } diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/OutboxConfig.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/OutboxConfig.cs index d526195ba3..0b327c0e3b 100644 --- a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/OutboxConfig.cs +++ b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/OutboxConfig.cs @@ -7,6 +7,13 @@ public class OutboxConfig { [NotNull] public string Name { get; } + + [NotNull] + public string DatabaseName { + get => _databaseName; + set => _databaseName = Check.NotNullOrWhiteSpace(value, nameof(DatabaseName)); + } + [NotNull] private string _databaseName; public Type ImplementationType { get; set; } diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs index 1b4f0e4deb..14e80bd9c6 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs @@ -27,7 +27,7 @@ public class InboxProcessor : IInboxProcessor, ITransientDependency protected DateTime? LastCleanTime { get; set; } - protected string DistributedLockName => "AbpInbox_" + InboxConfig.Name; + protected string DistributedLockName { get; private set; } public ILogger Logger { get; set; } protected CancellationTokenSource StoppingTokenSource { get; } protected CancellationToken StoppingToken { get; } @@ -64,6 +64,7 @@ public class InboxProcessor : IInboxProcessor, ITransientDependency { InboxConfig = inboxConfig; Inbox = (IEventInbox)ServiceProvider.GetRequiredService(inboxConfig.ImplementationType); + DistributedLockName = $"AbpInbox_{InboxConfig.DatabaseName}"; Timer.Start(cancellationToken); return Task.CompletedTask; } diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs index 3f7e2dfd73..5f34761b17 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs @@ -22,7 +22,7 @@ public class OutboxSender : IOutboxSender, ITransientDependency protected IEventOutbox Outbox { get; private set; } protected OutboxConfig OutboxConfig { get; private set; } protected AbpEventBusBoxesOptions EventBusBoxesOptions { get; } - protected string DistributedLockName => "AbpOutbox_" + OutboxConfig.Name; + protected string DistributedLockName { get; private set; } public ILogger Logger { get; set; } protected CancellationTokenSource StoppingTokenSource { get; } @@ -51,6 +51,7 @@ public class OutboxSender : IOutboxSender, ITransientDependency { OutboxConfig = outboxConfig; Outbox = (IEventOutbox)ServiceProvider.GetRequiredService(outboxConfig.ImplementationType); + DistributedLockName = $"AbpOutbox_{OutboxConfig.DatabaseName}"; Timer.Start(cancellationToken); return Task.CompletedTask; } diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbInboxConfigExtensions.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbInboxConfigExtensions.cs index 8b3f17c58b..9d16d9b730 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbInboxConfigExtensions.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbInboxConfigExtensions.cs @@ -1,3 +1,4 @@ +using Volo.Abp.Data; using Volo.Abp.EventBus.Distributed; namespace Volo.Abp.MongoDB.DistributedEvents; @@ -8,5 +9,6 @@ public static class MongoDbInboxConfigExtensions where TMongoDbContext : IHasEventInbox { outboxConfig.ImplementationType = typeof(IMongoDbContextEventInbox); + outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName(); } } diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbOutboxConfigExtensions.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbOutboxConfigExtensions.cs index 6b91fec861..3914c1380d 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbOutboxConfigExtensions.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbOutboxConfigExtensions.cs @@ -1,4 +1,5 @@ -using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Data; +using Volo.Abp.EventBus.Distributed; namespace Volo.Abp.MongoDB.DistributedEvents; @@ -8,5 +9,6 @@ public static class MongoDbOutboxConfigExtensions where TMongoDbContext : IHasEventOutbox { outboxConfig.ImplementationType = typeof(IMongoDbContextEventOutbox); + outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName(); } }