WriteEatSleepRepeat
WriteEatSleepRepeat

Reputation: 3143

choosing between a Windows service and a web app

We have an ASP.NET website where user adds items to database. There are several sites on same server, each with its own database.

I need to implement a mechanism to check database for the state of each item. If item is unprocessed, submit it to a third party web-service.

I see two options:

  1. put the code in a webapp
  2. put the code in a Windows service

The first option has the advantage that the code knows which database to connect to.

With Windows service, it has to be aware of all databases, so it's harder to maintain. Also, if I have only one Windows service, it will have to use threads to process items in each database in parallel.

Maybe there's another way beside these two?

What are the other issues, and what would you recommend? Please explain your choice.

Upvotes: 0

Views: 123

Answers (2)

Garrison Neely
Garrison Neely

Reputation: 3289

I believe Windows Service is a good option compared to a web app, mainly because a web app would have to be triggered manually by someone, while a Windows Service can be running at all times, checking for updates.

There's another option, if you have access to each of the existing site's code. Why not write a Web Service that will submit data to your third party web service. Then in each of the existing web sites, modify the logic that stores changes in the database to also post the changes to your custom Web Service (or even skip the custom WS and call the third party directly).

Upvotes: 0

kenchilada
kenchilada

Reputation: 7559

This sounds like a good place for a message queue to be involved. Each item would be wrapped into a message and placed in the queue. The "item processor" (a service?) would subscribe to the queue and perform some work using each item as it arrives. How the messages get placed on the queue is up to you, but for an example you could have each site publish the "new item" message to the queue.

Queues can be a bit of an intimidating concept at first, but frameworks such as MassTransit can help. Well worth learning.

Upvotes: 1

Related Questions