User Tools

Site Tools




The FileCaller SIB Caller subscribes to topics on the mqtt and writes data to files.




  • Subscribe: .custom/topic
    • on message:
      • custom.inputFormat
      • If: custom.useFileLock
        • check if file is locked
        • create lock on file
          • on error: publish msg._sibheader.reQTopic
      • write data to file
      • If: custom.useFileLock
        • release file lock
      • Publish: msg._sibheader.responseTopic

Custom configuration

let FileCallerCustom = {
    _id: "fileSample:1",
    _name: "MyFileCaller",
    append: true,
    loggerCfg: {
	dest: {
	    file: false,
	    console: true,
	    mqtt: true
    init: ( thisCaller )=>{},
    inputFormat: (topic, msg, cb)=>{
    mqtt: "mqtt://localhost",
    path: "path/to/data/filename.txt",
    topic: "TOPIC/TO/SUB",
    useFileLock: false,
    lockOptions: {
        stale: 10000,
        realpath: true,
        lockfilePath: "./lockfile"
    write: (msg, path, cb)=>{
        // optional custom write method
        return cb(msg);
module.exports = FileCallerCustom;
  • _id: The unique ID of this service
  • _name: A plaintext description of this service
  • append: set to true if the caller should append to existing files
  • 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 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)
  • path: The path and filename to write to
  • mqtt: The MQTT connection string for the internal MQTT transport
  • topic: The MQTT topic to subscribe to on the internal MQTT transport
  • useFileLock: Set to true if the listener should use the file locking functionality
  • lockOptions: Options for the lock functionality.
    • stale: Duration in milliseconds in which the lock is considered stale, defaults to 10000 (minimum value is 5000)
    • realpath: Resolve symlinks using realpath, defaults to true (note that if true, the file must exist previously)
    • lockfilePath: Custom lockfile path. e.g.: If you want to lock a directory and create the lock file inside it, you can pass file as <dir path> and options.lockfilePath as <dir path>/dir.lock
sib/callers/filecaller.txt · Last modified: 2019/09/20 07:23 by hubbe