User Tools

Site Tools




The RESTListener SIB Listener publishes a REST service on a specified port. When a http-request is made to this server the listener transforms the payload and query string to a SIB message and triggers the workflow. If a response is received from the SIB framework before the HTTP session times out that response is sent to the REST client.




  • Start REST Server on .custom.port
    • on request:
      • make SIBMessage from HTTP Request
      • apply SIBHeader
      • Publish: .custom.topic
      • set responseTimeoutTimer
        • on timeout:
          • HTTP Response
  • Subscribe: .custom.topic/REQUEUE
    • on message:
      • custom.inputFormat
      • Publish: msg._sibheader.topic
  • Subscribe: .custom.topic/RESPONSE/#
    • on message:
      • if message passes custom.responseFilter or custom.responseFilter not set
        • .custom.outputFormat
        • HTTP Response

Custom configuration

var RESTServiceCustom = {
	_id: "restSample:1",
	_name: "SIB Rest Listener Sample",
	contentType: "application/json",
	port: {
                DEV: 8818,
                TEST: 8818,
                QA: 8818,
                PROD: 8818
        init: ( thisListener )=>{},
        inputFormat: (topic, msg, cb)=>{
	loggerCfg: {
		dest: {
			file: false,
			console: true,
			mqtt: true
	outputFormat: (topic, msg, cb)=>{
	publishInput: (msg, mqttClient)=>{
        	mqttClient.publish( msg._sibheader.topic, JSON.stringify( msg ) );
	mqtt: "mqtt://localhost",
	mqtt_timeout: 20000,
	responseFilter: (topic, msg) =>{
		return true;
	topic: "SIB/Samples/RestListener"
module.exports = RESTServiceCustom;
  • _id: The unique ID of this service
  • _name: A plaintext description of this service
  • contentType: MIME type of response data
  • port: Port to listen to REST requests on
  • init(thisListener): If defined this method is executed when the service is starting up as the last step of initialization. thisListener is a reference to the instance of the listener that does the method call.
  • inputFormat(topic, msg, cb): The method that is run on service activation. The original message is passed as the argument and the return value from this method must be a JSON formatted message conforming to the SIB message standard.
  • loggerCfg: A JSON Object defining what logger actions should be active for this service (see Logger Configuration
  • outputFormat(msg): This message is run on the response data before publishing to the response topic. The response message is passed as the argument and the return data must be a JSON formatted message conforming to the SIB message standard.
  • mqtt: The MQTT connection string for the internal MQTT transport
  • mqtt_timeout: Number of milliseconds to wait for a response on the MQTT transport before sending a timeout response to the REST Client
  • publishInput: If defined overrides the standard publishing to the internal MQTT transfer
  • responseFilter(topic, msg): If this is set and returns false the current response message will be ignored
  • topic: The MQTT topic to publish to on the internal MQTT transport
sib/listeners/restlistener.txt · Last modified: 2019/09/20 07:34 by hubbe