Skip to content

Commit

Permalink
MessageId should be unassigned in queue
Browse files Browse the repository at this point in the history
outgoingEnqueue and outgoingEnqueueCombi functions should not store messageId. outgoingUpdate function will do. This PR requires moscajs/aedes-packet#5
  • Loading branch information
gnought committed Jul 29, 2019
1 parent 6d35e00 commit 02242f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
42 changes: 29 additions & 13 deletions abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,16 +770,19 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
brokerCounter: 42,
messageId: 1
brokerCounter: 42
}

instance.outgoingEnqueue(sub, packet, function (err) {
t.error(err)
var stream = instance.outgoingStream(client)

stream.pipe(concat(function (list) {
t.deepEqual(list, [expected], 'must return the packet')
var packet = list[0]
t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
delete packet.messageId
t.deepEqual(packet, expected, 'must return the packet')
instance.destroy(t.end.bind(t))
}))
})
Expand Down Expand Up @@ -821,19 +824,26 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
brokerCounter: 42,
messageId: 1
brokerCounter: 42
}

instance.outgoingEnqueueCombi(subs, packet, function (err) {
t.error(err)
var stream = instance.outgoingStream(client)
stream.pipe(concat(function (list) {
t.deepEqual(list, [expected], 'must return the packet')
var packet = list[0]
t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
delete packet.messageId
t.deepEqual(packet, expected, 'must return the packet')

var stream2 = instance.outgoingStream(client2)
stream2.pipe(concat(function (list) {
t.deepEqual(list, [expected], 'must return the packet')
var packet = list[0]
t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
delete packet.messageId
t.deepEqual(packet, expected, 'must return the packet')
instance.destroy(t.end.bind(t))
}))
}))
Expand Down Expand Up @@ -916,16 +926,19 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
brokerCounter: 42,
messageId: 1
brokerCounter: 42
}

instance.outgoingEnqueueCombi([sub], packet, function (err) {
t.error(err)
var stream = instance.outgoingStream(client)

stream.pipe(concat(function (list) {
t.deepEqual(list, [expected], 'must return the packet')
var packet = list[0]
t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
delete packet.messageId
t.deepEqual(packet, expected, 'must return the packet')
instance.destroy(t.end.bind(t))
}))
})
Expand Down Expand Up @@ -959,16 +972,19 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
brokerCounter: 42,
messageId: 4242
brokerCounter: 42
}

instance.outgoingEnqueueCombi([sub], packet, function (err) {
t.error(err)
var stream = instance.outgoingStream(client)

stream.pipe(concat(function (list) {
t.deepEqual(list, [expected], 'must return the packet')
var packet = list[0]
t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
delete packet.messageId
t.deepEqual(packet, expected, 'must return the packet')

var stream = instance.outgoingStream(client)

Expand Down
3 changes: 0 additions & 3 deletions persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ function _outgoingEnqueue (sub, packet) {

this._outgoing[id] = queue
var p = new Packet(packet)
if (packet.messageId) {
p.messageId = packet.messageId
}
queue[queue.length] = p
}

Expand Down

0 comments on commit 02242f4

Please sign in to comment.