Advice on moving .NET code from WPF app to continuously run on the server
TL;DR: What is a good approach for creating an app (or service, or ?) on a Windows Server that can continuously monitor a SQL Server Database and process Entities that satisfy a certain state for processing?
-------------------
I have a WPF application that requires users to process incoming "Requests". We get Requests from several different endpoints in different formats and we have a workflow that handles these. That is...
- Query different endpoints, convert to our standardized format and import to our database. This sets the Request's QueueId to a known value representing the fact that is has been "Downloaded".
- "Verify" these Requests by making calls to other various endpoints/services. This can take between 1-30 seconds for each request (usually closer to 1) and changes the Request's QueueId to a known value representing the fact that is has been "Verified".
- Distribute those Requests to work queues for staff to manually process what we could not do automatically based on the state of the Request and information added during the "Verify" phase. We have built up a complex set of rules that inspect the state of the Request and its related tables and calculate what QueueId, representing a workflow, the request should then be distributed to.
Previously, this was all done in one WPF application. 1 user would choose a"system", representing an endpoint, and start a process that would do the query, import, conversion, verification, and distribution.
I've managed to extract step 1 (download and import) out to a Console Application that gets run as a Schedule Task every 15 minutes on a Windows Server. In the case where step 1 is done on the server, the server also handles the verification and distribution or any requests in the Downloaded state. However, some external systems require staff to manually download a file and move it to a known location for importing and staff can take other actions to move a Request into the Downloaded state, which means they then have to wait until the next 15 minute cycle of importing any pending orders processes.
Goal: I'd like to create a new process where the Windows Server can continually monitor for Requests on SQL Server that have the QueueId representing the Downloaded state, then Verify and Distribute them without querying the database 500 times a minute. Because my Model, Verification, and Distribute logic are all in their own projects, what I would know how to do would be create another Console application that relies on those projects and use the Task Scheduler to run once a minute.
Is there a better approach here? I'm developing in a bubble with no real .NET experts to turn to so any guidance and links to resources are appreciated.
EDIT: Changed some details about other ways Requests are put into the "Downloaded" state by manual file saving.
0 comments:
Post a Comment