我必须创建Java Springboot应用程序,其中我必须一次将请求发送到多个端点的时间表
说明 - 我有IP地址/端口,并且在DB中保存的时间频率。
我必须创建将在计划时间内运行的服务或作业。它将从数据库读取端点,并同时发送请求到每个端点。
示例数据:
10.20.30.111/8890 and time frequency 5 min
10.30.40.112/6764 and time frequency 2 min
意味着我必须创建服务,该服务将每5分钟发送每5分钟和10.30.40.112/6764
每2分钟向10.20.30.111/8890
发送一次。
如何创建将根据不同时间频率运行的服务并同时发送请求到多个端点。
Explanation - I have IP address/port and thier time frequency saved in DB.
I have to create service or job that will run on scheduled time. It will read endpoints from db and send request to each endpoint at same time.
Example data:
10.20.30.111/8890 and time frequency 5 min
10.30.40.112/6764 and time frequency 2 min
Means that i have to create service that will send request to 10.20.30.111/8890
every 5 min and 10.30.40.112/6764
to every 2 min.
How can I create that Service that will run based on different time frequency and send request to multiple endpoints at same time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以注入进入应用程序的配置类。假设已经(或可以)从数据库中读取(端点,频率)的所有时间表相关记录,则可以将这些记录转换为呼叫
taskscheduler.scheduuleatfixedrate
(转换频率到类型的间隔持续时间
)。例如,骨骼将是:
You can inject a TaskScheduler into a configuration class of your application. Assuming that all schedule-related records of (endpoint, frequency) are already (or can be) read from the database, you can translate each of these records to a calls to
TaskScheduler.scheduleAtFixedRate
(converting the frequency to interval of typeDuration
).For example, a skeleton would be: