CHMaagaard
CHMaagaard

Reputation: 76

How can I configure Wolverine for publish/subscribe with more non competing subscribers using SQL Server as transport

I would like to configure Wolverine for publish/subscribe pattern with more non-competing subscribers using SQL Server as transport. I can manage to set it up, but only with competing subscribers.

I have created a test solution where I have a publisher and two subscribers. The problem is that the subscribers are acting as competing consumers with my current configuration. How can I change my setup so the subscribers are not competing?

Publisher configuration:

return await Host.CreateDefaultBuilder(args)
    .UseWolverine(opts =>
    {
        const string connectionString = "Data Source=vpc-chma;Initial Catalog=Test;Integrated Security=True;TrustServerCertificate=True;";

        opts.UseSqlServerPersistenceAndTransport(connectionString, "myapp")

            // Tell Wolverine to build out all necessary queue or scheduled message
            // tables on demand as needed
            .AutoProvision()

            // Optional that may be helpful in testing, but probably bad
            // in production!
            .AutoPurgeOnStartup();

        opts.PublishAllMessages().ToSqlServerQueue("outbound");

        // Registering the hosted service here, but could do
        // that with a separate call to IHostBuilder.ConfigureServices()
        opts.Services.AddHostedService<Worker>();
    })
    .RunOaktonCommands(args);

First subscriber configuration:

return await Host.CreateDefaultBuilder(args)
    .UseWolverine(opts =>
    {
        const string connectionString = "Data Source=vpc-chma;Initial Catalog=Test;Integrated Security=True;TrustServerCertificate=True;";

        opts.UseSqlServerPersistenceAndTransport(connectionString, "myapp")

            // Tell Wolverine to build out all necessary queue or scheduled message
            // tables on demand as needed
            .AutoProvision()
            
            // Optional that may be helpful in testing, but probably bad
            // in production!
            .AutoPurgeOnStartup();

        opts.ListenToSqlServerQueue("outbound"); 
    })
    .RunOaktonCommands(args);

Second subscriber configuration: The second subscriber configuration is identical to the first subscriber configuration.

Upvotes: 0

Views: 166

Answers (0)

Related Questions