User Tools

Site Tools




The CRONListener SIB Listener triggers a dataflow according to a number of configured scedules.


  • Subscribe: .custom.reQTopic
    • on message:
      • Publish: msg._sibheader.topic
  • Subscribe: .custom.schedules[].topic/RESPONSE/#
    • on message:
      • if message passes responseFilter, or responseFilter is not set
        • custom.outputFormat
        • apply/copy SIBHeader
        • if exists .custom.publishOutput
          • .custom.publishOutput
        • else
          • Publish: .custom.schedules[].responseTopic
  • CRONSchedule: [.custom.schedules.schedule]
    • on trigger:
      • custom.inputFormat
      • Publish: .custom.schedules[x].topic

Custom configuration

var CRONCustom = {
	_id: "cronsample:1",
	_name: "SIB Cron Listener Sample",
	inputFormat: (topic, msg, callback)=>{
		callback( msg );
	loggerCfg: {
		dest: {
			file: false,
			console: true,
			mqtt: true
	outputFormat: (topic, msg, callback)=>{
		callback( msg );
        publishOutput: (msg, mqttClient)=>{
                mqttClient.publish( msg._sibheader.topic, JSON.stringify( msg ) );
	schedules: [
		{schedule: "*/30 * * * * *", topic:"SIB/SAMPLES/CRONLISTENER/EVERY30SECONDS", responseTopic: "SIB/SAMPES/OUT30", payload:{}},
		{schedule: "* * * * *", topic: "SIB/SAMPLES/CRONLISTENER/EVERYMINUTE", payload:{a:1}},
		{schedule: "*/2 * * * *", topic: "SIB/SAMPLES/CRONLISTENER/EVERYTWOMINUTES", payload:{a:2}, responseFilter:(topic,msg)=>{return (msg._sibheader.responder='a.b.c');}}
	mqtt: "mqtt://",
module.exports = CRONCustom;
  • _id: The unique ID of this service
  • _name: A plaintext description of this service
  • inputFormat(topic, msg, callback): 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(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 return data must be a JSON formatted message conforming to the SIB message standard.
  • publishOutput: If defined overrides the standard MQTT publish of the output data (to the responseTopic) and instead lets the publishOutput be responsible for publishing data to the output topic.
  • schedules: An array of JSON Objects describing the scheduling and topics to publish messages to
    • schedule: The CRON schedule that decides how often to trigger the data flow
    • topic: The topic to publish the message to
    • responseTopic: If set and a message is received on the RESPONSE topic corresponding to this schedule.topic, the received message will be outputFormatted and published to this topic
    • payload: The payload to send in the message for this schedule
    • responseFilter(topic, msg): Method that if it exists needs to return true for this response to be handled
  • mqtt: The MQTT connection string for the internal MQTT transport
  • topic: The MQTT topic to subscribe to on the internal MQTT transport
sib/listeners/cronlistener.txt · Last modified: 2018/12/07 13:10 by hubbe