Registry / messaging / node-red-contrib-posixmq-read

node-red-contrib-posixmq-read

JSON →
library0.2.0jsnpmunverified

A Node-RED node that reads from POSIX message queues on Linux/FreeBSD. Version 0.2.0, stable but low activity. It depends on the posix-mq native addon and nan. Unlike generic MQTT nodes, this allows direct low-level POSIX IPC access for high-performance local message passing.

npm install node-red-contrib-posixmq-read
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-P
N
node-red-contrib-posixmq-read
messagingjavascriptv0.2.0
harness data pending
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); };
Debug
Known issues
gotchaQueue name must start with a '/' and cannot exceed NAME_MAX (typically 255 chars).
fix
Ensure the queue name begins with '/' (e.g., '/myqueue').
affects: >=0.0.0
gotchaThe maxmsgs and msgsize values are subject to system limits (see /proc/sys/fs/mqueue/msg_max and msgsize_max).
fix
Check system limits with 'cat /proc/sys/fs/mqueue/msg_max' and adjust accordingly.
affects: >=0.0.0
gotchaposixmq.shift() returns false when queue is empty; must check with !== false, not just truthy.
fix
Use while ((n = posixmq.shift(readbuf)) !== false) { ... }
affects: >=0.0.0
gotchaThe node uses Buffer constructor which is deprecated in newer Node.js versions.
fix
Replace 'new Buffer(size)' with 'Buffer.alloc(size)' as shown in the quickstart.
affects: >=0.0.0
gotchaThe queue must be unlinked and closed in the 'close' event to avoid resource leaks.
fix
Always call posixmq.unlink() and posixmq.close() on node close.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'posix-mq'
Missing native addon dependency.
fix
Run '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.
fix
Set 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.
fix
Install 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.
fix
Ensure you used 'require('posix-mq')' and not a relative path.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
posix-mqrequiredCore native addon for POSIX message queue operations
nanrequiredNative Abstractions for Node.js, required by posix-mq
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
node-red-contrib-posixmq-read — npm install node-red-contrib-posixmq-read · libregistry