
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@twilson63/palmetto-rmq
Advanced tools
This module uses rabbitMQ as the pub/sub messaging component for palmetto flow applications.
This module uses rabbitMQ as the pub/sub messaging component for palmetto flow applications.
The default behavior works well if you want to have several subscribers that receive all messages.
Optional behavior is to utilize the roundRobin
option to distribute the message to the subscribers in a round-robin fashion.
In either configuration you can optionally provide a publishOnly
option. The returned instance will not receive any messages.
var io = require('@twilson63/palmetto-rmq')({
endpoint: 'amqp://guest:guest@localhost:5672',
app: '<appname>',
vhost: '<optional>'
})
io.on('foobar', function (msg) {
console.log(msg)
})
io.emit('send', msg)
var uuid = uuid.v4()
io.on(uuid, function (event) {
console.log(event.object)
})
io.emit('send', {
to: 'widget.all.request',
from: uuid,
subject: 'widget',
verb: 'all',
type: 'request',
object: {}
})
io.on('widget.all.request', function (event) {
// do work
var results = ...
io.emit('send', {
to: event.from,
subject: 'widget',
verb: 'all',
type: 'response',
object: results
})
})
The service listens to the widget.all.request
svc then uses the from
node to publish the response to.
//requestor-service.js
var requestorIo = require('@twilson63/palmetto-rmq')({
endpoint: 'amqp://guest:guest@localhost:5672',
app: '<requestorServiceName>',
vhost: '<optional>'
})
var handlerIo = require('@twilson63/palmetto-rmq')({
endpoint: 'amqp://guest:guest@localhost:5672',
app: '<handlerServiceName>',
vhost: '<optional>',
roundRobin: true,
publishOnly: true // only the 'handlerService' will listen for messages
}) // this instance shouldn't participate in `roundRobin` consumption
var uuid = uuid.v4()
//setup response msg handler
requestorIo.on(uuid, function (event) {
console.log(event.object)
})
//send request msg
handlerIo.emit('send', {
to: 'widget.all.request',
from: uuid,
subject: 'widget',
verb: 'all',
type: 'request',
object: {}
})
//handler-service.js
//multiple instances of this service running
var inboundIo = require('@twilson63/palmetto-rmq')({
endpoint: 'amqp://guest:guest@localhost:5672',
app: '<handlerServiceName>',
vhost: '<optional>',
roundRobin: true, // all instances of 'handlerService' will get 'roundRobin' msg distribution
publishOnly: false // and obviously listen for those msgs
})
var requestorIo = require('@twilson63/palmetto-rmq')({
endpoint: 'amqp://guest:guest@localhost:5672',
app: '<requestorServiceName>',
vhost: '<optional>'
})
//handle request messages
inboundIo.on(uuid, function (event) {
doSomething(event.object)
.then(resultObject => {
requestorIo.emit('send', {
to: event.from,
from: event.to,
subject: event.subject + '-response',
verb: event.verb + '-response',
type: 'response',
object: resultObject
})
})
.catch(error => {
requestorIo.emit('send', {
to: event.from,
from: event.to,
subject: event.subject + '-error',
verb: event.verb + '-error',
type: 'response',
object: error
})
})
})
FAQs
This module uses rabbitMQ as the pub/sub messaging component for palmetto flow applications.
The npm package @twilson63/palmetto-rmq receives a total of 2 weekly downloads. As such, @twilson63/palmetto-rmq popularity was classified as not popular.
We found that @twilson63/palmetto-rmq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.