SzymonPobiega / NServiceBus.Bridge

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

Good use case? #1

Open markgould opened 7 years ago

markgould commented 7 years ago

This seems like a pretty good fit for our system, just want to make sure there isn't a simpler solution.

We have a large monolithic system using MSSQL (that we are starting to rewrite pieces of) with most of the logic in stored procs. Right now I'm using triggers to put messages into an endpoint queue that a real endpoint processes and enriches before publishing/sending to downstream systems. It works, but I don't like having all the transport tables in this database for many reasons. I'd like to have a dedicated NSB only database to use for the SQL transport. The persistence data will live in the database with the business data it belongs to (I believe that's the recommended practice rather than keeping all the persistence and transport tables together)

This is what I'm thinking I can do with this:

I'm working on a spike to prove this out, but it seems like it should work just fine.

markgould commented 7 years ago

I'm getting the following error when trying to initialize the bridge: ---> (Inner Exception #0) System.Collections.Generic.KeyNotFoundException: The given key (NServiceBus.Routing.EndpointInstances) was not present in the dictionary. at NServiceBus.Settings.SettingsHolder.Get(String key) in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Settings\SettingsHolder.cs:line 94 at NServiceBus.Settings.SettingsHolder.Get[T]() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Settings\SettingsHolder.cs:line 72 at NServiceBus.Transport.SQLServer.SqlServerTransportInfrastructure.ConfigureSendInfrastructure() in

Here's the sample code: https://gist.github.com/markgould/0b3ae141791d08c0bf88a7c2be346487

I've tried setting up some routing in the initialization of the transport, but it didn't seem to make a difference.

markgould commented 7 years ago

Looks like this is due to SQLTransport 3.0.2 not using this commit https://github.com/Particular/NServiceBus.SqlServer/commit/4005b1a3ef8f9a74e2fa7389e3a93750610ae5b7#diff-734321b72d52bc31733b86191d75e96c

After upgrading to 3.1.0 from the MyGet feed, it appears to run!

markgould commented 7 years ago

I was able to get it to work from my SQL trigger insert. The key was to ensure I set the NServiceBus.Bridge.DestinationEndpoint and NServiceBus.MessageIntent headers. Now the bridge happily passes messages to the queue running on the other catalog. Cool!