Created
March 12, 2018 10:18
-
-
Save bondvt04/a0ea9ec03797086d468fc2aec0ab8473 to your computer and use it in GitHub Desktop.
RabbitMQ retries - creating retry set: 1 TTLX, 3 ttl queues and 1 DLX
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 }) | |
) | |
.concat(channel.assertExchange('TTL-COMMENTS', 'direct', { durable: true })) | |
.concat(channel.assertExchange('DLX-COMMENTS', 'fanout', { durable: true })) | |
); | |
} | |
function assertQueues() { | |
return Promise.all([] | |
.concat(channel.assertQueue('comments', { durable: true })) | |
.concat([ | |
channel.assertQueue('comments-retry-1-30s', { durable: true, deadLetterExchange: 'DLX-COMMENTS', messageTtl: 30000 }), | |
channel.assertQueue('comments-retry-2-10m', { durable: true, deadLetterExchange: 'DLX-COMMENTS', messageTtl: 600000 }), | |
channel.assertQueue('comments-retry-3-48h', { durable: true, deadLetterExchange: 'DLX-COMMENTS', messageTtl: 195840000 }), | |
]) | |
); | |
} | |
function bindExchangesToQueues() { | |
return Promise.all([] | |
.concat( | |
channel.bindQueue('comments', 'A_COMMENT_CREATED'), | |
channel.bindQueue('comments', 'A_COMMENT_DELETED'), | |
channel.bindQueue('comments', 'A_COMMENT_UPDATED') | |
) | |
.concat(channel.bindQueue('comments', 'DLX-COMMENTS')) | |
.concat( | |
channel.bindQueue('comments-retry-1-30s', 'TTL-COMMENTS', 'retry-1'), | |
channel.bindQueue('comments-retry-2-10m', 'TTL-COMMENTS', 'retry-2'), | |
channel.bindQueue('comments-retry-3-48h', 'TTL-COMMENTS', 'retry-3') | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment