rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.26k stars 353 forks source link

Outbox difficulty #1132

Closed dazinator closed 5 months ago

dazinator commented 5 months ago

https://github.com/rebus-org/Rebus/wiki/Outbox

I took me a while to find this api, turns out you need to bring in the package Rebus.SqlServer not just Rebus.Outbox.SqlServer not sure if its worth mentioning on wiki.

I spoke prematurely.

I am having difficulty finding this api.

I am using packages

When I try to use this API, there are none that configure an IOutboxStorage - these are the ones I see:

image

e.g I see this extension method offered for DataBus storage, Saga storage, Saga snapshot storage, Subscription storage, and Timeout Manager storage.

Could someone point me in the right direction? I was hoping to configure the outbox with a conn string and table name.

dazinator commented 5 months ago

I found it in the end by removing Rebus.Outbox package which was interfering. I now just have Rebus.SqlServer and all is well.

One thing I noticed and not sure how much of an issue it really is but the extension method for sql outbox is just called "Outbox()" and its directly on RebusConfigurer - it gives the illusion that by calling Outbox() you are provider agnostic, and only when you call StoreInSqlServer() you are accessing provider specefic apis.

image

So it seems like Postgres would carry its own "Outbox" extension method too, and then you'd conflict although I am not sure why you'd have both packages present. It looks like there may have previously been a standard abstraction for IOutboxStorage but the general purpose Outbox() configuration extension method as a standard way to configure this, and the provider specific extension methods for sql server and the like would have been on this - which seems much nicer, but that has been done away with. This makes it sllightly different from how Transports and other things are configured and this non uniform implemenation means it has been more difficult for me to create a wrapper to allow me to configure rebus entirely from IConfiguration and the Microsoft Extensions Options package.

mookid8000 commented 5 months ago

Hi @dazinator , you're right that Rebus + Rebus.SqlServer is enough to run Rebus using MSSQL Server as the outbox.

(..) it gives the illusion that by calling Outbox() you are provider agnostic, and only when you call StoreInSqlServer() you are accessing provider specefic apis (...)

Well, I can certainly understand why you might think that if you're not used to Rebus - but it's a general pattern in Rebus:

services.AddRebus(configure => configure.Transport(t => {});

doesn't do anything, while

services.AddRebus(configure => configure.Transport(t => t.UseAzureServiceBus(...));

does. That's just how it is with Rebus 🙂

Btw. there's no such thing as being "provider agnostic" with Rebus' outbox implementation - it is very much coupled to MSSQL Server.

Oh, and if you want to use the Postgres outbox, you'll go

services.AddRebus(
    configure => configure
        .Transport(t => t.Use(...)
        .Outbox(o => o.StoreInPostgreSql(...))
);

but yes, you're right that the .Outbox extension happens to be defined by the outbox provider - this is because the outbox is not "core Rebus functionality", so the Rebus core library does not know anything about the concept. This can of course clash a bit if you're using both MSSQL and PostgreSQL in the same project.

Let me know if you have further questions. 🙂

dazinator commented 5 months ago

Thanks

but yes, you're right that the .Outbox extension happens to be defined by the outbox provider

Thanks that it was I was trying to say in a roundabout way. I think most of the other api's have their provider specific extension method not directly on the RebusConfigurer. I appreciate outbox isn't provider agnostic but just as transport providers don't carry their own Transport() extension method I thought it might be beneficial to keep that conistent when it comes to the way outbox is configured in the fluent api. (clash avoidance, and discoverability)

Anyway no big deal, everything seems working now, thank you ;-)