events - 当数据到达过期时间时向 RabbitMQ 发布事件
问题描述
我目前正在使用事件驱动的架构。我们有一些数据在我们的数据库中有过期时间。什么是在数据过期的确切时刻发布事件(数据过期)的最佳解决方案?我想实时执行此操作,而不是执行调度程序进程或批处理。
解决方案
I think to achieve that you will need the DB to have some mechanism to support that. And I can't think of any right now (even less without knowing which DB).
But from the top of my head, I can say: if that expiration date is never modified after being inserted in DB, you could just insert a message in RabbitMQ at the same moment that you insert the data in DB. You would set a TTL in the message, and configure dead lettering in that queue. That way, when the message expires it gets automatically published to another exchange.
You can read more here: https://www.rabbitmq.com/dlx.html
推荐阅读
- javascript - 在对话框中按下按钮时,专注于 TextField 不起作用 - Material UI
- django - 解析模板中 django modelformset 中返回的 json
- c++ - 如何使用函数作为参数使列表的内容进入无序映射?
- node.js - 无法解析 privateKey:不支持的密钥格式
- python - Python:如何在不单独打印每条消息的情况下将消息写入列表中的项目?
- python - Python - 加速度计以 1 kHz 速率读取和写入 CSV 文件
- javascript - change the number of the iterator in a for loop
- python - nslookup 在 python 中使用服务器替代
- php - laravel 5.7中返回变量的问题
- selenium-webdriver - 机器人框架打开浏览器并创建 WebDriver 在更新后不起作用