Skip to content

Commit 6238a74

Browse files
beemanTom Kirkpatrick
authored andcommitted
feat: pass the full message into the consumer as second param
1 parent 8a0f9e2 commit 6238a74

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/mixins/message-queue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function messageQueueMixin(Model, options) {
2929
const RabbitMQ = loopback.getModel('RabbitMQ')
3030

3131
try {
32-
return Model[name](msg.body)
32+
return Model[name](msg.body, msg)
3333
.then(() => {
3434
debug('consumer %s ran successfully for model %s. key: %o',
3535
name, Model.modelName, msg.fields.routingKey)

test/mixin.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ describe('Mixin', function() {
5858
expect(app.models.Client.consumeNewItems.calledOnce).to.be.true()
5959
})
6060
it('should pass the message body to the consumer', function() {
61-
expect(app.models.Client.consumeAllItems.calledWith('a message')).to.be.true()
62-
expect(app.models.Client.consumeNewItems.calledWith('a message')).to.be.true()
61+
expect(
62+
app.models.Client.consumeAllItems.calledWithMatch('a message', { type: 'item.write.created' })).to.be.true()
63+
expect(
64+
app.models.Client.consumeNewItems.calledWithMatch('a message', { type: 'item.write.created' })).to.be.true()
6365
})
6466
})
6567
})

0 commit comments

Comments
 (0)