diff --git a/lib/mixins/message-queue.js b/lib/mixins/message-queue.js index d3f1f4b..5e88278 100644 --- a/lib/mixins/message-queue.js +++ b/lib/mixins/message-queue.js @@ -29,7 +29,7 @@ module.exports = function messageQueueMixin(Model, options) { const RabbitMQ = loopback.getModel('RabbitMQ') try { - return Model[name](msg.body) + return Model[name](msg.body, msg) .then(() => { debug('consumer %s ran successfully for model %s. key: %o', name, Model.modelName, msg.fields.routingKey) diff --git a/test/mixin.test.js b/test/mixin.test.js index cebd73b..7ac2634 100644 --- a/test/mixin.test.js +++ b/test/mixin.test.js @@ -58,8 +58,10 @@ describe('Mixin', function() { expect(app.models.Client.consumeNewItems.calledOnce).to.be.true() }) it('should pass the message body to the consumer', function() { - expect(app.models.Client.consumeAllItems.calledWith('a message')).to.be.true() - expect(app.models.Client.consumeNewItems.calledWith('a message')).to.be.true() + expect( + app.models.Client.consumeAllItems.calledWithMatch('a message', { type: 'item.write.created' })).to.be.true() + expect( + app.models.Client.consumeNewItems.calledWithMatch('a message', { type: 'item.write.created' })).to.be.true() }) }) })