Registry /
messaging / node-red-contrib-posixmq-read
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PosixMQReadNode
✓ module.exports = function (RED) { function PosixMQReadNode(config) { ... } RED.nodes.registerType('posixmq-read', PosixMQReadNode); }
✗ module.exports = function (RED) { RED.nodes.registerType('posixmq-read', function(config) { ... }); }
Must export a Node-RED node constructor function registered with RED.nodes.registerType. The function must be named and have config parameter.
PosixMQ
✓ var PosixMQ = require('posix-mq');
✗ var PosixMQ = require('node-red-contrib-posixmq-read');
The underlying C++ addon is at package 'posix-mq', not this node's package.
posixmq-read
✓ npm install node-red-contrib-posixmq-read
✗ npm install posixmq-read
The package name on npm includes 'node-red-contrib-' prefix.
Demonstrates a complete Node-RED node that reads from a POSIX message queue and outputs the concatenated messages on input.
// Place this in a Node-RED function node or as a custom node file
var PosixMQ = require('posix-mq');
module.exports = function (RED) {
function PosixMQReadNode(config) {
RED.nodes.createNode(this, config);
this.msgname = config.msgname;
this.msgsize = Number(config.msgsize);
this.maxmsgs = Number(config.maxmsgs);
var posixmq = new PosixMQ();
var node = this;
var readbuf = Buffer.alloc(posixmq.msgsize);
node.on('input', function () {
var str = '';
var n;
while ((n = posixmq.shift(readbuf)) !== false) {
str += readbuf.toString('utf8', 0, n);
}
if (str.length > 0) {
node.send({ payload: str });
}
});
node.on('close', function () {
posixmq.unlink();
posixmq.close();
});
}
RED.nodes.registerType('posixmq-read', PosixMQReadNode);
};
Errors
Common errors & fixes
Error: Cannot find module 'posix-mq'
Missing native addon dependency.
fixRun 'npm install posix-mq' in the Node-RED user directory (typically ~/.node-red).
Error: Failed to open posix mq: No such file or directory
The queue does not exist and create option is false.
fixSet create: true in the open config, or create the queue first using posix-mq or mq_open().
Error: Cannot find module 'nan'
Missing native addon build dependency.
fixInstall nan globally or locally: 'npm install nan'.
TypeError: posixmq.open is not a function
The posix-mq package was not required correctly or is an older version.
fixEnsure you used 'require('posix-mq')' and not a relative path. Audit
Dependencies
posix-mqrequiredCore native addon for POSIX message queue operations
nanrequiredNative Abstractions for Node.js, required by posix-mq