Skip to content

Commit af9bfd8

Browse files
authored
remove autodelete (#8)
1 parent 3d22859 commit af9bfd8

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@elastic.io/amqp-rpc",
33
"description": "RPC over RabbitMQ for Node.js",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"homepage": "http://elastic.io",
66
"author": "elastic.io GmbH <[email protected]>",
77
"main": "src/index.js",

src/AMQPEventsReceiver.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ class AMQPEventsReceiver extends EventEmitter {
3535
async receive() {
3636
assert(!this._channel && !this._queue, 'Already receiving');
3737
this._channel = await this._connection.createChannel();
38-
this._queue = await this._channel.assertQueue(this._queueName, {
39-
autoDelete: true,
40-
durabale: true
38+
const queue = await this._channel.assertQueue(this._queueName, {
39+
durable: true
4140
});
42-
this._channel.consume(this._queue.queue, this._handleMessage.bind(this));
43-
return this._queue.queue;
41+
this._queueName = queue.queue;
42+
this._channel.consume(this._queueName, this._handleMessage.bind(this));
43+
44+
return this._queueName;
4445
}
4546

4647
/**
@@ -53,7 +54,7 @@ class AMQPEventsReceiver extends EventEmitter {
5354
const channel = this._channel;
5455
this._channel = null;
5556
try {
56-
await channel.deleteQueue(this._queue.name);
57+
await channel.deleteQueue(this._queueName);
5758
} catch (e) {
5859
//it's ok to ignore this error, as queue
5960
//may be deleted by AMQPStreamSender

test/unit/AMQPEventsReceiver.test.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ describe('AMQPEventsReceiver', () => {
2525

2626

2727
describe('#contructor', () => {
28-
it('should set default queueName', () => {
28+
29+
it('should be event emitter', () => {
2930
const receiver = new AMQPEventsReceiver(connectionStub);
30-
expect(receiver).to.be.instanceof(AMQPEventsReceiver);
3131
expect(receiver).to.be.instanceof(EventEmitter);
32+
});
33+
34+
it('should set connection', () => {
35+
const receiver = new AMQPEventsReceiver(connectionStub);
3236
expect(receiver._connection).to.equal(connectionStub);
33-
expect(receiver._queueName).to.equal('');
3437
});
3538

3639
it('should set default queueName', () => {
3740
const queueName = 'q';
3841
const receiver = new AMQPEventsReceiver(connectionStub, queueName);
39-
expect(receiver).to.be.instanceof(AMQPEventsReceiver);
40-
expect(receiver).to.be.instanceof(EventEmitter);
41-
expect(receiver._connection).to.equal(connectionStub, queueName);
4242
expect(receiver._queueName).to.equal(queueName);
4343
});
4444
});
@@ -66,19 +66,18 @@ describe('AMQPEventsReceiver', () => {
6666
expect(receiver._channel).to.equal(channelStub);
6767
});
6868

69-
it('should create amqp queue with autoDelete and durable flags', async () => {
69+
it('should create amqp queue with options', async () => {
7070
const receiver = new AMQPEventsReceiver(connectionStub, 'q');
7171
const queueStub = {
72-
queue: 'q'
72+
queue: 'q1'
7373
};
7474
channelStub.assertQueue = sinon.stub().returns(Promise.resolve(queueStub));
7575
const queueName = await receiver.receive();
7676
expect(channelStub.assertQueue).to.have.been.calledOnce
77-
.and.calledWith(receiver._queueName, {
78-
autoDelete: true,
79-
durabale: true
77+
.and.calledWith('q', {
78+
durable: true
8079
});
81-
expect(receiver._queue).to.equal(queueStub);
80+
expect(receiver._queueName).to.equal(queueStub.queue);
8281
expect(queueName).to.equal(queueStub.queue);
8382
});
8483

0 commit comments

Comments
 (0)