views:

1071

answers:

3

I need to submit data from a web application to console application. The current plan calls for the web app to submit data to the database and the console app to poll the database then act on the data when it is inserted. Should I change the console app to include an http handler that the web app can submit data so it doesn't have to poll the database? Is there a better way to communicate data between these two applications? The console app never has to send data to the web app.

Update

This is a .NET 2.0 console application so WCF doesn't seem like a viable option. The data payload is fairly small (a few 9 digit ID fields, less than 150 bytes total), and will be sent with a rate of about 10 per minute. There is no firewall between these two applications.

+2  A: 

I'm not sure of your requirements, or setup but WCF could be an option.

[edit]
To expand, you could host a wcf service in the console app, and have the asp.net site call it. For that matter, remoting (or any other form) could work as well. This way you wouldn't have to have the console app pool the database when not necessary.

Joe
This is a great answer. I've just made this solution the other day. Works like a charm. First I used Named-pipes, but those are too few for high performance sites. So now I have a WCF service hosted (servicehost) in my console application (which will be a real service running the background once we get it completed and tested 100%)
BerggreenDK
A: 

You basically want an app to app communication. There are a lot of options, but really depend on your requirement (how much data, how big, how often, latency), environment (behind firewall, online/offline, recovery) and so on.

Using a Database is one solution. But you could use others - like webservice (wcf), messaging system(msmq), .net remoting even.

LeJeune
A: 

Using the simplest technologies, your Console App could connect to the database in a loop controlled by a Timer or a BackgroundWorker. You would need a way to know what records are new and which aren't. If you can delete the records from that table when you poll them, it means each time you do it, you'll get only new records. If you can't delete them, use a TimeStamp field in that table and each time you poll you select the recrods with that time stamp greater than the maximum time stamp of the previous batch. If you need to mark those records as processed, then you can set that flag and forget about the timestamp.

Sergiu Damian