sql-servermqttservice-broker

SQL Server 2008 Service Broker to MQTT Mosquitto Broker


We have an old SQL Server 2008 system that needs to communicate to our MQTT broker (Mosquitto). We intend to use trigger method as outlined here

However I do not know enough about enabling the SQL Service Broker, what do I need to get the SQL Service Broker to communicate to the Mosquito Broker.

What do we need besides the SQL Service Broker enabled?

So for example I have a trigger somewhat like the example in the web page

DECLARE @dialog_handle UNIQUEIDENTIFIER;

BEGIN DIALOG @dialog_handle  
FROM insertedData
TO SERVICE 'MosquitoService';  
SEND ON CONVERSATION @dialog_handle (@Message) ; 

How can we accomplish this ? We do not need SQL server to receive messages , we only need to publish messages ..


Solution

  • You need to write a program that reads from the queue backing MosquitoService and writes to MQTT.

    Here's an old sample of how to read from Service Broker in .NET: https://github.com/microsoftarchive/msdn-code-gallery-community-s-z/tree/master/Service%20Broker%20Message%20Processor%20Service%20Sample