@hostv2hp/common
Advanced tools
Comparing version 1.0.60 to 1.0.61
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Listener = void 0; | ||
class Listener { | ||
constructor(client) { | ||
this.ackWait = 5 * 1000; | ||
this.client = client; | ||
} | ||
subscriptionOptions() { | ||
return this.client | ||
.subscriptionOptions() | ||
.setDeliverAllAvailable() | ||
.setManualAckMode(true) | ||
.setAckWait(this.ackWait) | ||
.setDurableName(this.queueGroupName); | ||
} | ||
listen() { | ||
const subscription = this.client.subscribe(this.subject, this.queueGroupName, this.subscriptionOptions()); | ||
subscription.on('message', (msg) => { | ||
console.log(`Message received: ${this.subject} / ${this.queueGroupName}`); | ||
const parsedData = this.parseMessage(msg); | ||
this.onMessage(parsedData, msg); | ||
}); | ||
} | ||
parseMessage(msg) { | ||
const data = msg.getData(); | ||
return typeof data === 'string' | ||
? JSON.parse(data) | ||
: JSON.parse(data.toString('utf8')); | ||
} | ||
} | ||
exports.Listener = Listener; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Publisher = void 0; | ||
class Publisher { | ||
constructor(client) { | ||
this.client = client; | ||
} | ||
publish(data) { | ||
return new Promise((resolve, reject) => { | ||
this.client.publish(this.subject, JSON.stringify(data), (err) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
console.log('Event published to subject', this.subject); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
} | ||
exports.Publisher = Publisher; |
{ | ||
"name": "@hostv2hp/common", | ||
"version": "1.0.60", | ||
"version": "1.0.61", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18458
505