views:

371

answers:

7

Hi All,

I have a require ment to read data from a table(SQL 2005) and send that data to other application for every 5 seconds. I am looking for the best approach to do the same.

Right now I am planning to write a console application(.NET and C#) which will read the data from sql server 2005(QUEUE table which will be filled through different applications) and send to other application through TCP/IP(Central server). Run that console application under schedule task for every 5 seconds. I am assuming scheduled task will take care to discard new run event if task is already running(avoid to run concurrent executions).

Does any body come accross similar situation? Please share your experience and advice me for best approach.

Thanks in advance for your valuable time spending for my request.

-Por-hills-

A: 

I would recommend writing a Windows Service (since you are C#) that has some timer which runs every 5 seconds. That way you wont be starting and stopping an application all the time, it can run even when there is no one logged into the machine, and it will automatically start when the machine is restarted.

Tetraneutron
Hi T,Thanks for attempting my thread. I thought to use windows service but after reading the following blog have confused and that is the reason am taking advice from all of you Here is the link :http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx
porhills
I think the distinguishing point here is every 5 seconds isn't exactly one off, if it was sending something once a day then I can see his point, but with a system which is potentially sending data continuously over the day a windows service still sounds like the best choice to me.
Tetraneutron
Why write custom code when you have a product in the house already?I would use an SSIS package scheduled in SQL Server Agent job? All the scheduling, error notification, etc. is built in! All I have to worry about is automating my business functionality.
Raj More
A: 

For one of my projects, I needed to do something periodically. I opted for a service and set up a timer that takes care of reading the data. You might consider that solution. It has worked well for me.

itsmatt
Hi,Thanks for attempting my thread. I thought to use windows service but after reading the following blog have confused and that is the reason am taking advice from all of you Here is the link :http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx
porhills
A: 

I suggest to create a windows service and not an application and to perform the timing yourself - create a timer and execute one step on each timer event. For the communication you have many choices - I would consider using standard technologies like a webservice or Winows Communication Foundation.

Besides this custom solution I would evaluate if the task can be solved using Microsoft Integration Services .

Finally other question comes to mind - why do you need this application? Why doesn't/don't the application(s) consuming the data query the database? Is the expensive polling required? Is it possible for the data producers to signal the availibilty of new data directly to the data consumers?

Daniel Brückner
Hi Daniel,Thanks for attempting my thread.Answers to your questions:We are in Orders(raw material) delivery business and we have winform application which will run on each csr machine and those people will take an order through telephone and those orders will be queued in one table.Those orders to be full filled through our back end service(third party) and we have to send customized message to that back end service through TCP/IP port.
porhills
+1  A: 

We have done simliar work. If you are going to query a sql database every 5 seconds, be sure to use a stored procedure that is optimized to be very fast. It should not update data unless aboslutely necessary. This approach is typically called 'polling' and I've found that it is acceptable if your sqlserver is not otherwise bogged down with too many other calls.

In approaches we've used, a Windows Service that does the polling works well.

To communicate results to another app, it all depends on what your other app is doing and what type of interface you can make into it, and how quickly you need the results. The WCF class libraries from Microsoft provide many workable approaches for real time communication. My preference is to write to the applications database, and then have the application read the data (if it works for that app). If you need something real time, WCF is the way to go, and I'd suggest using a stateless protocol like http if < 5 sec response time is required, (using standard HTTP posts), or TCP/IP if subsecond response time is required.

Dale Wilbanks
Hi Dale, Thanks for attempting my thread.Yes, I am going to query sql database and that query is very simple select statement like SELECT guid,message from InterfaceMessages where status = 'ReadToSend'I thought to use windows service but after reading the following blog have confused and that is the reason am taking advice from all of youHere is the link : http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspxAnswer to another app: The other application is java based service and it will lisetn for incoming requests a particular port.
porhills
A: 

I am not sure about the details of your project, specifically related to security but maybe it would be better to create an SSIS package and schedule it as a job?

CountCet
Hi Thanks for attempting my thread.Here are details about my projectWe are in Orders(raw material) delivery business and we have winform application which will run on each csr machine and those people will take an order through telephone and those orders will be queued in one table.Those orders to be full filled through our back end service(third party) and we have to send customized message to that back end service through TCP/IP port
porhills
There are many better ways to handle this. I think you may want to explore exchanging messages with WCF but that is something I am not an expert in.
CountCet
A: 

since I assume your central storage is also SQL 2005, have you considered using what SQL Server 2005 offers out of the box to achieve your requirements? Rather than pool every 5 seconds, marshal and unmarshal TCP/IP, implement authentication and authorization for the TCP/IP pipe, scale TCP transmission with boxcaring, manage message acknowledgments and retries, deal with central site availability, fragment large messages, implement fairness in transmission and so on and so forth, why not simply use Service Broker? It does all you need and more, out of the box, already tested, already tuned for performance and scalability.

Getting reliable messaging right is not trivial and you should focus your efforts in meeting your business specifics, not reiventing the wheel.

Remus Rusanu
I haven't think about SQL Service Broker. I will defenetly look at your options. Thanks for your advice.
porhills
A: 

Is message queuing not an option?

johnnycrash