简体   繁体   English

开发TCP Communicator的最佳实践

[英]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. 在该系统中,我们将GPS设备固定到车辆中,该车辆使用TCP通信将位置数据发送到我们的服务器。 There can be more than 1000's of devices sending data at any given time. 在任何给定时间,可以有超过1000个设备发送数据。 Please suggest me the best practices I should follow to build the TCP communicator. 请建议我应该遵循的最佳实践来构建TCP通信器。 We are using java as programming language and MySQL as database server. 我们使用java作为编程语言,使用MySQL作为数据库服务器。

I need your suggestions on best practices I should follow along with the reasons. 我需要你对我应该遵循的最佳实践的建议以及原因。 eg I should follow Thread-per-connection model or Thread-on-event model of multi-threading? 例如,我应该遵循Thread-per-connection模型或多线程的事件线程模型? Why that model? 为什么那个型号? How should I implement connection pooling? 我该如何实现连接池? Shall I implement messaging queue?,etc.. 我应该实现消息队列?等。

Thanks, Saurabh 谢谢,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. 我使用Mule3作为tcp服务器监听器,然后在读取数据后,我只是使用JMS将数据转发到ActiveMQ服务器。

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. 我在处理数据的每个队列上有大约10-20个侦听器,将其放入我的数据库,对数据运行规则以确定是否需要发送警报等。

This resultet in a very stable an easy to work environment. 这导致了一个非常稳定且易于工作的环境。 Small modules with specific tasks. 具有特定任务的小模块。

  1. Use NIO and make full use of multi-threading. 使用NIO并充分利用多线程。 If possible use some exisitng libraries like MINA 如果可能的话,使用一些像MINA这样的现有库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM