Quartz .Net 架构问题
这是场景。我有一个应用程序可以出于多种原因与服务器保持持续连接。我需要从网络服务器获取或发布到网络服务器的三组通用对象。
业务数据对象。这本质上是从服务器拉到客户端计算机并存储在本地数据库中的数据。如果用户更新本地计算机上的数据,则会被标记并需要发送以与服务器同步。大约有 6 个自定义类需要提取数据并将数据发送到服务器(需要时)。
文件。正如它所说,这种同步是针对文件的。文件可以上传到服务器。但更重要的是,文件可以下载到客户端。将会有从服务器自动发送的文件和其他按需文件。
连接/登录查询。这些同步将从服务器提取用户信息并定期检查更新的信息并验证权限。还需要进行检查以确保应用程序已连接到服务器,如果连接丢失,则进行适当的处理。
我对 Quartz 很陌生,正在尝试想出最好的方法来设置我想要发生的这 3 个不同的同步。我有几个问题。
如果我想要多个线程池,我是否只想创建 3 个独立的调度程序工厂?我如何通过配置来实现这一点,或者我需要对其进行编码以在工厂的每次实例化之前显式设置 Quartz 属性?
业务数据对象同步有时会是最重的负载。当用户首次登录或被分配附加权限时,可能会要求他们从服务器下载最多 10K 对象/记录。这种情况很少发生,理想情况下,用户会连接,数据会全部下载,5-10 分钟后他们就可以使用该应用程序来实现其目的。此同步需要不断检查服务器以查看它们是否是新数据并监视本地数据以查看是否需要将新数据发送到服务器。让一个工厂用它自己的线程池(例如 10 个线程)处理所有这些是否有意义?
最终,我只是想弄清楚如何最初规划整个过程并将其分开以轻松管理它们并正确执行。这是为了概念证明,任何帮助将不胜感激。请随意批评以上任何内容。
谢谢!
Here is the scenario. I have an application that can be in constant connection with a server for multiple reasons. There are three general sets of objects that I need to get from or post to a webserver.
Business Data Objects. This is essentially data that gets pulled down from the server to client machines and stored in a local DB. IF a user updates the data on their local machine, it gets flagged and needs to be sent up to be synched with the server. There are approx 6 custom classes that will need to pull down data and send data to the server (when needed).
Files. Just as it states, this synch is for files. Files can be uploaded to the server. But more importantly, files can be downloaded to the client. There will be files that are automatically sent from server and other files that will be on demand.
Connection / Login queries. These synchs will pull user information from the server and regularly check for updated info and verify permissions. There also needs to be a check to make sure that the application is connected to the server, and if connection is lost, then handle that appropriately.
I am very new to Quartz and am trying to think of the best way to setup these 3 distinct synchronizations that I want to happen. I have a few questions.
If I wanted multiple thread pools, would I just want to create 3 separate scheduler factories? How would I accomplish this with a config, or would I need to have it coded to explicitly set Quartz properties prior to each instantiation of the factory?
The business data objects synchronization will be the heaviest load at times. When a user first logs in, or is assigned additional permissions, they can be required to download up to 10K objects/records from the server. This would be an infrequent occurrence, and ideally the user would connect, the data would all download, and 5-10 minutes later they can use the application for their purposes. This synch would need to constantly check the server to see if their is new data and monitor local data to see if new data needs to be sent to server. Would it make sense to have a factory handle all of this with it's own thread pool of say, 10 threads?
Ultimately, I am just trying to figure out how to initially plan out this entire process and split things apart to easily manage them and do it correctly. This is for a proof of concept and any help would be great appreciated. Please feel free to critique any of the above.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过实现 Quartz.Spi.IThreadPool 来插入自定义线程池。调度程序只有一个
IThreadPool
,但您可以在该单个接口后面屏蔽多个线程池,尽管实现需要有关正在调度的作业的信息,以便将它们派生到每个线程。默认实现 Quartz.Simpl.SimpleThreadPool 具有固定(可配置)数量的线程,所有线程都具有相同(可配置)优先级。
否则,正如您所说,您可能有多个调度程序。这更容易,您只需拥有多个独立的调度程序工厂,但它们不应该共享任何状态。
You can plug a custom thread pool by implementing
Quartz.Spi.IThreadPool
. A scheduler only has a singleIThreadPool
, but you may be able to mask multiple thread pools behind that single interface, although the implementation would need information about the jobs being scheduled in order to derive them to each thread.The default implementation,
Quartz.Simpl.SimpleThreadPool
, has a fixed (configurable) number of threads, all with the same (configurable) priority.Otherwise, you could have multiple schedulers as you said. This is easier, you'd just have multiple independent scheduler factories, but they should not share any state.