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: 8818,
	inputFormat: (msg)=>{
		return msg;
	loggerCfg: {
		dest: {
			file: false,
			console: true,
			mqtt: true
	outputFormat: (msg)=>{
		return msg;
	mqtt: "mqtt://",
	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
  • inputFormat(msg): 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
  • responseFilter(topic, msg): If this is set and returns false the current response message will be ignored
  • topic: The MQTT topic to subscribe to on the internal MQTT transport
sib/listeners/restlistener.txt · Last modified: 2018/12/07 10:49 by hubbe