Skip to content

Commit

Permalink
feat: pass the full message into the consumer as second param
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Mar 28, 2017
1 parent 8a0f9e2 commit 62f623f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/mixins/message-queue.js
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions test/mixin.test.js
Expand Up @@ -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()
})
})
})

0 comments on commit 62f623f

Please sign in to comment.