Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow registered dependencies to be used when configuring endpoints with UseNServiceBus #421

Open
awright18 opened this issue Aug 21, 2023 · 0 comments
Labels
Improvement New feature or request

Comments

@awright18
Copy link
Contributor

Describe the suggested improvement

Is your improvement related to a problem? Please describe.

It doesn't seem possible to resolve a dependency from the ServiceProvider for use when calling UseNServiceBus.

The specific instance where this could be helpful is when using SqlPersistance with MutlipleTenants.

Example:

  Host.CreateDefaultBuilder(args)
    .ConfigureServices(services =>
    {
        services.AddSingleton<ConnectionStringBuilder>();
    })
    .UseNServiceBus(c =>
    {
      var endpointConfiguration = new EndpointConfiguration(endpointName);
    
      var persistence = endpointConfiguration.UsePersistence<SqlPersistence>();
        persistence.SqlDialect<SqlDialect.MsSqlServer>();
    
      persistence.MultiTenantConnectionBuilder(tenantIdHeaderName: "TenantId",
            buildConnectionFromTenantData:
            tenantId =>
            {            
                return new //Can't figure out how to resolve ConnectionStringBuilder 
                   SqlConnection(ConnectionStringBuilder.GetConnectionStringForTenant(tenantId)); 
            });
     }

Describe the suggested solution

Provide some way to resolve the dependencies inside UseNServiceBus

Describe alternatives you've considered

A static method is being used to provide the functionality to get the tenant-specific connection string.

Additional Context

No response

@awright18 awright18 added the Improvement New feature or request label Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant