Is WCF the right choice for a long data import process?

I am currently creating a process for our business that takes some data from a database (A), does some work on the data, and then copies it to another table in another database (B). The amount of data that we process as a whole, and we expect this process to take a lot of time (weeks).

Is it a smart design choice for this kind of task to use WCF? So, I thought that I might have some kind of client application / web interface (which the rest of the business can use) to โ€œqueryโ€ / display the progress of the overall import process. I would also like to give clients the ability to start / pause / stop the import process through the service.

Is this capable in WCF? Is this even the right choice? I suppose that in some way this should act like a regular Windows service (I just thought it would be easier to โ€œrequestโ€ the import progress using some methods that I could open through WCF?)

In addition, can I encounter problems, for example, if one user tried to start / stop the import process at the same time? Is a singleton template an application to ensure that everyone works with the same single import process?

Any thoughts / ideas are greatly appreciated.

+6
source share
2 answers

Edit / Foreword: this answer assumes that you want to use WCF only for user interaction with the process, and not for linking the entire software stack, and that the main work is done using the longest maintenance.

Yes, this can be done in WCF, and this is probably the right solution. You will have a long processor thread that often requests / updates a certain set of interaction properties (for example, it will update the percentage that it does, which element it works, and check the pause flag, etc.). These properties, in turn, will be requested / set using the WCF interface methods.

The syntax template is ideal for this - if your stream setting is configured correctly, users will interact with some properties that check for a long stream (or streams).

From an extremely high level point of view, the processor class will probably look something like this (in principle, how can this be done, donโ€™t do it exactly like that, otherwise I will have nightmares):

// IWcfProcessor is the ServiceContract interface // Processor runs as a singleton and does (or has a thread that does) the processing work class Processor : IWcfProcessor { public Processor() { new Thread(Process).Start(); } public void Process() { while (Run) { // Do long-running process stuff, update some tables PercentDone += 0.1; } } public decimal PercentDone { get; set; } public bool Run { get; set; } /// WCF method defined in IWcfProcessor public void SetState(bool state) { Run = state; } /// WCF method defined in IWcfProcessor public decimal GetStatus() { return PercentDone; } } 

You can then connect to the IWcfProcessor from the endpoint of the network or application.

In addition, I may run into problems, for example, if one user tried to start / stop the import process at the same time, etc.?

Assuming that you have correctly configured thread switching, you will have no problem.

Is the application a singleton to make sure everyone works with the same single import process?

Yes, that's great.

+2
source

Yes. This can work with WCF streaming. Here, look at my answer to another similar question.

+2
source

Source: https://habr.com/ru/post/913435/


All Articles