SzymonPobiega / NServiceBus.Bridge

A bridge that can connect endpoints using different NServiceBus transports
MIT License
4 stars 3 forks source link

Change in bridge subscription under 2.0.0-rc0002 #17

Open theezak opened 6 years ago

theezak commented 6 years ago

Hi,

Previously subscription persistence could be configured for example like this:

bridge.UseSubscriptionPersistence<InMemoryPersistence>((config, persistence) => { config.LicensePath(@"license.xml"); });

But the signature of this method has changed under 2.0.0. How can you configure persistence under 2.0.0 rc0002?

SzymonPobiega commented 6 years ago

Hi @theezak

I've removed the InMemoryPersistence because it was not really meant for any production use as it may cause message loss if the bridge restarts (the subscription cache would be empty until the communicating endpoints themselves restart and send subscribe messages).

Out of the box you can now use SQL subscription persistence as demonstrated here https://github.com/SzymonPobiega/NServiceBus.Bridge/blob/release-2.0/src/NServiceBus.Bridge.AcceptanceTests/When_using_sql_persistence.cs#L17

For the tests you can copy the in-memory persistence from the acceptance tests.

Note that the latest release uses built-in subscription persistence and does not depend on NServiceBus persistence.

theezak commented 6 years ago

Hi,

What would be the correct implementation of the following sample when InMem is dropped?

https://docs.particular.net/samples/azure/azure-service-bus-msmq-bridge/

` var bridgeConfiguration = Bridge .Between("Bridge-MSMQ") .And("Bridge-ASB", transport => { transport.ConnectionString(connectionString); transport.UseForwardingTopology(); });

bridgeConfiguration.AutoCreateQueues(); bridgeConfiguration.UseSubscriptionPersistece((configuration, persistence) => { }); `

SzymonPobiega commented 6 years ago

@theezak You should use SqlSubscriptionStorage as described in that sample. The constructor for this storage requires a Func<DbConnection> connectionBuilder for building connections, a table name prefix, a SQL dialect to use and a cache duration.