This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// emulate some job which can be failed | |
function handler() { | |
return Math.random() > 0.1 ? Promise.resolve() : Promise.reject() | |
} | |
channel.consume('comments', msg => { | |
return (new Promise((resolve, reject) => { | |
if (msg.fields.redelivered) { | |
reject('Message was redelivered, so something wrong happened'); | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assertExchanges() | |
.then(assertQueues) | |
.then(bindExchangesToQueues); | |
function assertExchanges() { | |
return Promise.all([] | |
.concat( | |
channel.assertExchange('A_COMMENT_CREATED', 'fanout', { durable: true }), | |
channel.assertExchange('A_COMMENT_DELETED', 'fanout', { durable: true }), | |
channel.assertExchange('A_COMMENT_UPDATED', 'fanout', { durable: true }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const AmqpClient = require('amqplib'); | |
const Promise = require('bluebird'); | |
const contentTypeJson = 'application/json'; | |
const contentEncoding = 'utf8'; | |
const config = { | |
exchanges: [ | |
{ name: 'A_COMMENT_CREATED', type: 'fanout' }, | |
{ name: 'A_COMMENT_DELETED', type: 'fanout' }, |