User Tools

Site Tools




The MSSQL SIB Caller is a specific MSSQL caller that performs operations on a MSSQL database. The caller simply performs the [msg.sql] operation on the database and returns the result. It is recommended to generate the [msg.sql] field in the inputFormat, overwriting whatever value was received from the MQTT transport, for safety reasons. The [msg.sql] field can then be deleted in the outputFormat method if needed.




  • Subscribe: .custom.topic
    • on message:
      • custom.inputFormat
        • if msg.result is set
          • Respond with result from inputFormat
        • else
          • Perform operation on database
          • custom.outputFormat
          • Publish message on responseTopic with the result from the database operation

Custom configuration

var MSSQLCallerCustom = {
	_id: "mssqlSample:1",
	_name: "MSSQLCallerSample",
	init: ( thisCaller )=>{},
	inputFormat: (topic, msg, cb)=>{
		msg.sql = "SELECT * FROM table WHERE field='value'";
	loggerCfg: {
		dest: {
			file: false,
			console: true,
			mqtt: true
	mssql: {
		host: "localhost",   // You can use 'localhost\\instance' to connect to named instance
		user: "sibtest",
		password: "base64encodedpw",
		database: "sibtest"
	outputFormat: (topic, msg, cb, mysqlConnection)=>{
		delete( msg.sql );
	mqtt: "mqtt://localhost",
	topic: "SIB/test/MSSQLCaller"
module.exports = MSSQLCallerCustom;
  • _id: The unique ID of this service
  • _name: A plaintext description of this service
  • init(thisCaller): If defined this method is executed when the service is starting up as the last step of initialization. thisCaller is a reference to the instance of the caller that does the method call.
  • inputFormat(topic, msg, callback): The method that is run on service activation. The original message is passed as the argument and the input value to the callback must be a JSON formatted message conforming to the SIB message standard. If msg.result is set in the returned message no further database actions will be taken by the caller.
  • loggerCfg: A JSON Object defining what logger actions should be active for this service (see Logger Configuration
  • mssql: Database configuration. The below fields are required but everything that can be passed to mysql.connect can be set here
    • host: The host of the database server
    • user: The user to log in as
    • password: The password for the user, base64 encoded
    • database: The database to connect to
  • outputFormat(topic, msg, callback): This message is run on the response data before publishing to the response topic. The response message is passed as the argument and the input to the callback must be a JSON formatted message conforming to the SIB message standard.
  • mqtt: The MQTT connection string for the internal MQTT transport
  • topic: The MQTT topic to subscribe to on the internal MQTT transport
sib/callers/mssqlcaller.txt · Last modified: 2019/09/20 07:25 by hubbe