Ok. I updated the module. However it's probably fine to have the AbpDistributedEventBus use MongoDB in the same database.
However I had to add code to configure the SQL dbcontexts
Configure<AbpDbContextOptions>(options => { options.Configure<PermissionManagementDbContext>(dbContextOptions => { dbContextOptions.UseSqlServer(); }); ... remaining Sql db contexts
Here's the revised MemberConfigDbContext
using CloverleafCMS.MemberConfig.Members;
using MongoDB.Driver;
using Volo.Abp.Data;
using Volo.Abp.MongoDB;
using Volo.Abp.MongoDB.DistributedEvents;
namespace CloverleafCMS.MemberConfig.Data;
[ConnectionStringName(DatabaseName)]
public class MemberConfigDbContext :
AbpMongoDbContext,
IHasEventInbox,
IHasEventOutbox
{
public IMongoCollection<Member> Members => Collection<Member>();
public const string DatabaseName = "MemberConfig";
public IMongoCollection<IncomingEventRecord> IncomingEvents => Collection<IncomingEventRecord>();
public IMongoCollection<OutgoingEventRecord> OutgoingEvents => Collection<OutgoingEventRecord>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);
modelBuilder.ConfigureEventInbox();
modelBuilder.ConfigureEventOutbox();
}
}
I was able to build and run the application. However when I execute the post route of the API I get this error: Error] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": null, "validationErrors": null }
3/5/2025 9:15:38 PM [Error] Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.MembersAppServiceProxy -> CloverleafCMS.MemberConfig.Members.MongoMemberRepository.
---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'CloverleafCMS.MemberConfig.Members.MongoMemberRepository' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.MongoDB.IMongoDbContextProvider1[CloverleafCMS.MemberConfig.Data.MemberConfigDbContext] dbContextProvider' of constructor 'Void .ctor(Volo.Abp.MongoDB.IMongoDbContextProvider1[CloverleafCMS.MemberConfig.Data.MemberConfigDbContext])'.
See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
It looks like you'd didn't read the full question.
We're on Abp V9 and I generated the solution and microservice using Abp Studio version 09.23. This is the solution configuration.
The document link you sent looks like it's based on a previous version of the Microservice template and assumes you want to change everything to MongoDb. In our case we want the Abp microservices as well as most of our microservices to use SQL Server and a couple of other microservices to use MongoDB.
In the new Microservice (MemberConfig) I created withAbp Studio I selected MongoDb for the database provider. The solution that was generated is all MongDb including DistributedEvents, FeatureManagement, LanguageManagement, PermissionManagement and SettingManagement.
Below I've copied the DbContext and CloverleafCMSMemberConfigModule deleting what I thought was irrelevant code.
Please tell me what I need to update/add/delete so that the DistributedEvents, FeatureManagement, LanguageManagement, PermissionManagement and SettingManagement packages use SQL Server and the rest of the MemberConfig microservice use MongDb?
It would be very helpful to know that someone on the Abp team has gone through similar steps using a current version of everything (ABP Studio, Abp Suite and Microservice template).
This is the MemberConfigDbContext class
...other usings
using Volo.Abp.LanguageManagement;
using Volo.Abp.PermissionManagement;
using Volo.Abp.SettingManagement;
using Volo.Abp.Studio.Client.AspNetCore;
using Volo.Abp.Swashbuckle;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.MongoDB;
using Volo.Abp.PermissionManagement.MongoDB;
using Volo.Abp.LanguageManagement.MongoDB;
using Volo.Abp.FeatureManagement.MongoDB;
using Volo.Abp.AuditLogging.MongoDB;
using Volo.Saas.MongoDB;
using Volo.Abp.BlobStoring.Database.MongoDB;
using Volo.Abp.MongoDB.DistributedEvents;
namespace CloverleafCMS.MemberConfig;
[DependsOn(
typeof(BlobStoringDatabaseMongoDbModule),
typeof(AbpSettingManagementMongoDbModule),
typeof(LanguageManagementMongoDbModule),
typeof(AbpPermissionManagementMongoDbModule),
typeof(AbpFeatureManagementMongoDbModule),
typeof(AbpAuditLoggingMongoDbModule),
typeof(SaasMongoDbModule),
... other DependsOn,
typeof(AbpHttpClientModule)
)]
And this is the CloverleafCMSMemberConfigModule class
public class CloverleafCMSMemberConfigModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var env = context.Services.GetHostingEnvironment();
var redis = CreateRedisConnection(configuration);
... other configures
ConfigureDatabase(context);
... other configures
context.Services.TransformAbpClaims();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
var configuration = context.GetConfiguration();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
... other code
}
private void ConfigureDatabase(ServiceConfigurationContext context)
{
Configure<AbpDbConnectionOptions>(options =>
{
options.Databases.Configure("Administration", database =>
{
database.MappedConnections.Add(AbpPermissionManagementDbProperties.ConnectionStringName);
database.MappedConnections.Add(AbpFeatureManagementDbProperties.ConnectionStringName);
database.MappedConnections.Add(AbpSettingManagementDbProperties.ConnectionStringName);
});
options.Databases.Configure("AuditLoggingService", database =>
{
database.MappedConnections.Add(AbpAuditLoggingDbProperties.ConnectionStringName);
});
options.Databases.Configure("SaasService", database =>
{
database.MappedConnections.Add(SaasDbProperties.ConnectionStringName);
});
options.Databases.Configure("LanguageService", database =>
{
database.MappedConnections.Add(LanguageManagementDbProperties.ConnectionStringName);
});
});
context.Services.AddMongoDbContext<MemberConfigDbContext>(options =>
{
options.AddDefaultRepositories();
});
context.Services.AddAlwaysDisableUnitOfWorkTransaction();
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
}
private void ConfigureDistributedEventBus()
{
Configure<AbpDistributedEventBusOptions>(options =>
{
options.Inboxes.Configure(config =>
{
config.UseMongoDbContext<MemberConfigDbContext>();
});
options.Outboxes.Configure(config =>
{
config.UseMongoDbContext<MemberConfigDbContext>();
});
});
}
private void ConfigureIntegrationServices()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ExposeIntegrationServices = true;
});
}
private void ConfigureObjectMapper(ServiceConfigurationContext context
{
context.Services.AddAutoMapperObjectMapper<CloverleafCMSMemberConfigModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<CloverleafCMSMemberConfigModule>(validate: true);
});
}
Not sure if anyone else using MacOs is having this issue but when running the Microservice solution in Abp Studio, if I stop a service (or all services) it doesn't actually stop the process. If I try to restart the service it just keeps restarting and exiting.
If I navigate to the Swagger url for the service it brings it up (e.g. localhost:44317/swagger) so obviously it hasn't stopped.
The only work around I've found is to restart my Mac.
Below are screenshots of the Adminstration Service supposedly stopped and the exiting with Code 1 continuously after I restart it.
We added the logger statements to all of the services and the auth server but they showed they were the same.
But, our other developer remembered that we had changed our default pass phrases when we deployed our apps to AKS. So the appsettings running localhost and the environment variables in the AKS deployment were different. The SMTP user password in our test tenant must have been set & hashed with localhost before we moved our apps to AKS. He reset the SMTP password with the current default pass phrase settings and the problem went away.
Thank you for pointing us in the right direction. Also, if you can direct to any documentation on how the default pass phrase is used across your packages and templates that would be helpful. This seems to be the only issue resulting from changing the default pass phrases.
Where do I put public override void OnApplicationInitialization(ApplicationInitializationContext context) { var env = context.GetEnvironment(); var app = context.GetApplicationBuilder();
var opt = app.ApplicationServices.GetRequiredService<IOptions<AbpStringEncryptionOptions>>();
Logger.LogInformation("pass phrase is : " + opt.DefaultPassPhrase);
.....
}
What module/program file within the Authserver solution?
Hi,
I don't understand your response. What do you mean?: "This is a problem with your StringEncryption. They used different values, so setting values could not be decrypted."
Different values from what? We have the StringEncryption in the Kubernetes pod config environment variables in the authserver application:
Where else is the StringEncryption?
Why was this closed. You all haven't answered the question.
Hi,
Yes I can see the password for the tenant but it is null for the host which is our requirement. Each tenant will have their own SMTP servers, usernames, etc.
Where would I put Logger statement?
Thank you.
Thanks. That was helpful