Enable outbox, Isolated worker, .NET7

Hi!

We are stuck when trying to enable outbox during endpoint configuration.

We can recreate the issue using the downloadable example named service-bus-worker_asbfunctionsworker_4_net7_0.zip

We are getting the following error:

Outbox requires transport to be running in ReceiveOnly mode. Use the TransportTransactionMode property on the transport definition to specify the transaction mode.

We saw the known limitation regarding AdvancedConfiguration.UseTransport(..), and instead use the .Transport property.

The added code compared to the downloaded example code is:

        .UseNServiceBus((configuration, endpointConfiguration) =>
        {
            var persistence = endpointConfiguration.AdvancedConfiguration.UsePersistence<SqlPersistence>();
            persistence.SqlDialect<SqlDialect.MsSqlServer>();
            persistence.ConnectionBuilder(() => new SqlConnection("<connection string>"));
            persistence.TablePrefix("_NSB_");
            
            endpointConfiguration.Transport.TransportTransactionMode = TransportTransactionMode.ReceiveOnly;
            endpointConfiguration.AdvancedConfiguration.EnableOutbox();
        })

And except for the packages provided with the example, the follwing are added:

<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.11" />
<PackageReference Include="NServiceBus.Persistence.Sql" Version="7.0.2" />

Do you have any advice to give us?

Kind regards,
Robert Sandberg

Or can we omit the two lines below altogether and outbox will be enabled by default when configuring persistance?

endpointConfiguration.Transport.TransportTransactionMode = TransportTransactionMode.ReceiveOnly;
endpointConfiguration.AdvancedConfiguration.EnableOutbox();

When we omit those two lines, and we shutdown our database before sending out the FollowupMessage() in the TriggerMessageHandler, then it fails because as we understood, it tries to write to the outbox in database. Is this assumption correct?

Hi Robert!

I think we have a bug, I was able to repro your issue and fix it in Force transaction mode to receive only to allow outbox to be used by andreasohlund · Pull Request #383 · Particular/NServiceBus.AzureFunctions.Worker.ServiceBus · GitHub

I’ll discuss this further and let you know when we can get a fix out, I’ll keep you posted on this thread.

Cheers,

Andreas

2 Likes

Okey, great to know. We were going insane not knowing if we where doing things completely off. I almost had to call Jens on his vacation :slight_smile:

We are somewhat blocked by this, so looking forward to your fix.

Kind Regards,
Robert

Hi Robert!

I’ve done some more testing and I can confirm that the workaround to set

endpointConfiguration.Transport.TransportTransactionMode = TransportTransactionMode.ReceiveOnly;

works on version 4.1.0. Would you be able to upgrade to it? (since the sample use 4.* nuget will default to 4.0.0 :poop: )

Cheers,

Andreas

Hi Andreas!

We just checked, and even though have have set NServiceBus.AzureFunctions.Worker.ServiceBus to 4.* we get 4.1.0. It seems that * respects our wish to get the highest stable version.

So we have the issue with 4.1.0. We’ve tested it on two machines (Mac + Windows).

Regards,
Robert

Sorry for the confusion, we have now released 4.1.1 and 4.2.1 to address this issue. Let us know if you have any further issues!

Cheers,

Andreas

Thanks for the quick response and fixes! We’ve verified it as working in 4.2.1.

Kind regards,
Robert