开发者

ASP.NET MVC Background Service processing

We run a number of ASP.NET MVC sites - one site per client instance with about 50 on a server. Each site has its own configuration/database/etc.

Each site might be running on a slightly different version of开发者_StackOverflow社区 our application depending on where they are in our maintenance schedule.

At the moment for background processing we are using Quartz.net which runs in the app domain of the website. This works well mostly but obviously suffers issues like it isn't running when the appdomain shuts down such as after prolonged activity.

What are our options for creating a more robust solution?

Windows Services are being discussed but I don't know how we can achieve the same multi-site on different versions we get within IIS.

I really want each IIS site to have its own background processing which always runs like a service but is isolated in the same way an IIS site is.


You could install a windows service for each client. That seems like a maintenance headache though.

You could also write a single service that understands all versions of your app, then processes each client one after the other.

You could also create sql server jobs to do this, and setup one job for each customer.


I assume that you have multiple databases for each client as you mentioned. Create a custom config file with db connection-strings for each client.

e.g.

<?xml version="1.0" encoding="utf-8" ?>
<MyClients>
  <MyClient name="Cleint1">
    <Connection key="Client1" value="data source=<database>;initial catalog=client1DB;persist security info=True;user id=xxxx;password=xxxx;MultipleActiveResultSets=True;App=EntityFramework" />       
  </MyClient>
  <Myclient name="client2".....></MyClient>
</MyClients>

Write a windows service which loads the above config file (clients|connectiostring) into the memory and iterate through each client database config. I guess all clients have similar job queuing infrastructure, so that you can execute same logic against each database.

You can use a Mutex to initiate the windows service for a client so that it will make sure two instances of the service for the same client won't run at the same time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜