Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions extensions/notification/deliveryWorker/DeliveryKafkaProducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const joi = require('joi');

const KafkaProducer = require('../destination/KafkaProducer');

/**
* Producer used by the delivery worker to publish notifications to an
* external destination.
*
* It behaves like the notification KafkaProducer, with an added bound on
* how long librdkafka keeps retrying a message before it expires. The
* delivery worker holds the consumer offset until the delivery report is
* received, so an unbounded retry would block the offset forever.
*/
class DeliveryKafkaProducer extends KafkaProducer {

getConfigJoi() {
return super.getConfigJoi()
.append({ deliveryTimeoutMs: joi.number() });
}

getClientId() {
return 'NotificationDeliveryProducer';
}

setFromConfig(joiResult) {
super.setFromConfig(joiResult);
this._deliveryTimeoutMs = joiResult.deliveryTimeoutMs;
}

get topicConfig() {
const base = super.topicConfig;
if (this._deliveryTimeoutMs === undefined) {
return base;
}
return {
...base,
'message.timeout.ms': this._deliveryTimeoutMs,
};
}

}

module.exports = DeliveryKafkaProducer;
Loading
Loading