Send message reliably from Windows Service to Azure Service Fabric Stateful Service using NServicebus

260 Views Asked by At

I have a Windows service that will run outside of my Azure Service Fabric. I need to be able to reliably send messages from the windows service to my stateful service fabric (over HTTP, as this will be on a separate network), preferably using NServicebus. I am unsure where to start, I've got NServicebus installed on my windows service. The network is extremely unreliable, so durable messaging is key.

2

There are 2 best solutions below

0
On

If you want to tunnel through HTTP(S) for security/infrastructure reasons, I recommend having a look at the gateway component of NServiceBus. Is was specifically built for these multi-site scenarios. It gives you exactly-one message delivery over an unreliable HTTP(S) connection. Check it out: https://docs.particular.net/nservicebus/gateway/

  1. Set up an NServiceBus endpoint with MSMQ on the box with the Windows Server. It will use the built-in store and forward capabilities of MSMQ not to lose messages locally on that machine.

  2. Set up one or more NServiceBus endpoints in Azure Service Fabric. There you would probably use ASB as transport for service to service communication.

  3. Use the NServiceBus gateway to bridge between 1) and 2) through a HTTP(s) channel. It will do automatic retries if the connection is down and it does de-duplication to give you exactly-once message delivery through HTTP(s).

3
On

If you are already hosting your service fabric solution in Azure I would recommend you use Azure Service Bus transport with NServiceBus to send messages (Queues or Topics) to your Microservices.

there will be some boilerplate code to implement in the Microservices to receive and consume the messages, but it can be managed with Dependency Injection while bootstrapping your Service (Startup).