Best Practises for developing a TCP Communicator
We are developing a Vehicle Tracking System. In this system, we fix a GPS device into the vehicle which sends the location data to our server using TCP communication. There can be more than 1000's of devices sending data at any given time. Please suggest me the best practices I should follow to build t开发者_运维百科he TCP communicator. We are using java as programming language and MySQL as database server.
I need your suggestions on best practices I should follow along with the reasons. e.g. I should follow Thread-per-connection model or Thread-on-event model of multi-threading? Why that model? How should I implement connection pooling? Shall I implement messaging queue?,etc..
Thanks, Saurabh
I have built a similar system. I used Mule3 for the tcp server listener and then after reading the data I just forwarded the data using JMS to an ActiveMQ server.
I had around 10-20 listeners on each queue processing the data, putting it in my database, running rules over the data to determine if alarms need to be sent etc.
This resultet in a very stable an easy to work environment. Small modules with specific tasks.
- Use NIO and make full use of multi-threading. If possible use some exisitng libraries like MINA
精彩评论