Flow
Kita bisa pake rabbitmq buat bikin retry mechanism. kurang lebih flownya nanti setelah client kirim message, nanti dia di delay dulu sesuai TTL baru masuk ke queue.
Disini kita akan pakai bahasa pemrograman kotlin
Deklarasi Exchange
JSON
Copy
val args: MutableMap<String, Any> = HashMap()
args["x-delayed-type"] = "direct"
chanel.exchangeDeclare(RabbitMQExchange.MAIL_TARGET, "x-delayed-message", true, false, args)
chanel.queueDeclare(RabbitMQQueue.WEBHOOK_DELAY, true, false, false, args)
chanel.queueBind(
RabbitMQQueue.WEBHOOK_DELAY,
RabbitMQExchange.MAIL_TARGET,
RabbitMQRoutingKey.WEBHOOK_DELAY
)
Install
instal dari repo ini rabbitmq-delayed-message-exchange