Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

servicebus

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

servicebus - npm Package Compare versions

Comparing version 1.0.16 to 1.0.17

13

bus/rabbitmq/bus.js

@@ -143,7 +143,16 @@ var amqp = require('amqplib'),

RabbitMQBus.prototype.destroyListener = function removeListener (queueName) {
if (this.queues[queueName] === undefined) {
RabbitMQBus.prototype.destroyListener = function removeListener (queueName, options) {
options = options || {};
if ( ! options.force && this.queues[queueName] === undefined) {
throw new Error('no queue currently listening at %s', queueName);
} else {
var q = this.queues[queueName];
if (! q && options.force) {
var em = new events.EventEmitter();
this.listenChannel.deleteQueue(queueName, { ifEmpty: false })
.then(function (ok) {
em.emit('success');
});
return em;
}
delete this.queues[queueName];

@@ -150,0 +159,0 @@ return q.destroy();

7

bus/rabbitmq/pubsubqueue.js

@@ -12,3 +12,3 @@ var events = require('events');

extend(queueOptions, {
autoDelete: ! (options.ack || options.acknowledge),
autoDelete: options.autoDelete || ! (options.ack || options.acknowledge),
contentType: options.contentType || 'application/json',

@@ -130,3 +130,6 @@ durable: Boolean(options.ack || options.acknowledge),

self.log('asserting error queue ' + self.errorQueueName);
self.listenChannel.assertQueue(self.errorQueueName, self.queueOptions)
var errorQueueOptions = extend(self.queueOptions, {
autoDelete: options.autoDeleteErrorQueue || false
});
self.listenChannel.assertQueue(self.errorQueueName, errorQueueOptions)
.then(function (_qok) {

@@ -133,0 +136,0 @@ _subscribe(uniqueName);

@@ -10,3 +10,3 @@ var EventEmitter = require('events').EventEmitter;

extend(queueOptions, {
autoDelete: ! (options.ack || options.acknowledge),
autoDelete: options.autoDelete || ! (options.ack || options.acknowledge),
contentType: options.contentType || 'application/json',

@@ -50,2 +50,5 @@ durable: Boolean(options.ack || options.acknowledge),

self.log('asserting error queue %s', self.errorQueueName);
var errorQueueOptions = extend(self.queueOptions, {
autoDelete: options.autoDeleteErrorQueue || false
});
self.listenChannel.assertQueue(self.errorQueueName, self.queueOptions)

@@ -52,0 +55,0 @@ .then(function (_qok) {

@@ -10,3 +10,3 @@ {

"description": "Simple service bus for sending events between processes using amqp.",
"version": "1.0.16",
"version": "1.0.17",
"homepage": "https://github.com/mateodelnorte/servicebus",

@@ -13,0 +13,0 @@ "repository": {

@@ -6,2 +6,3 @@ var noop = function () {};

var should = require('should');
var sinon = require('sinon');

@@ -120,2 +121,21 @@ describe('servicebus', function(){

it('should allow ack:true and autodelete:true for publishes', function (done) {
var expectation = sinon.mock();
var subscription = bus.subscribe('my.event.30', { ack: true, autoDelete: true }, function () {
expectation();
});
setTimeout(function () {
bus.publish('my.event.30', {});
setTimeout(function () {
subscription.unsubscribe();
setTimeout(function () {
expectation.callCount.should.eql(1);
bus.destroyListener('my.event.30', { force: true }).on('success', function () {
done();
});
}, 100);
}, 100);
}, 100);
});
// it('should allow for a mixture of ack:true and ack:false subscriptions', function () {

@@ -122,0 +142,0 @@

@@ -5,2 +5,3 @@ var noop = function () {};

var confirmBus = require('./bus-confirm-shim').bus;
var sinon = require('sinon');
var util = require('util');

@@ -110,2 +111,20 @@

});
it('should allow ack:true and autodelete:true for sends', function (done) {
var expectation = sinon.mock();
bus.listen('my.event.25', { ack: true, autoDelete: true }, function () {
expectation();
});
setTimeout(function () {
bus.send('my.event.25', {});
bus.unlisten('my.event.25').on('success', function () {
setTimeout(function () {
expectation.callCount.should.eql(1);
bus.destroyListener('my.event.25', { force: true }).on('success', function () {
done();
});
}, 100);
});
}, 100);
});

@@ -112,0 +131,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc