简体   繁体   English

使用哪种Delphi技术?

[英]Which Delphi technology to use?

I have a Client/Server application written Delphi. 我有一个用Delphi编写的Client / Server应用程序。 Essentially all the application is doing is transferring xml data streams between a server application and connected clients. 基本上所有应用程序正在做的是在服务器应用程序和连接的客户端之间传输xml数据流。 I am currently using the Indy TIdTCPServer component. 我目前正在使用Indy TIdTCPServer组件。 But the server side application keeps crashing on some of my installments. 但是服务器端应用程序在我的部分安装中不断崩溃。 And it has been extremely difficult to debug. 调试非常困难。 So I am wondering if there is some "architecture" I should be utilizing which does all the tcp/ip connection management and database connection pooling, allowing me to concentrate on the business logic. 所以我想知道是否有一些“架构”,我应该利用它来完成所有tcp / ip连接管理和数据库连接池,让我专注于业务逻辑。

Here are more details: 这里有更多细节:

  • clients must maintain a "persistent" connection. 客户必须保持“持久”连接。 There are times when the server must notify and send data to all connected clients. 有时服务器必须通知并向所有连接的客户端发送数据。
  • clients are connecting from laptop computers using wireless aircards. 客户使用无线空中卡通过笔记本电脑连接。 So network "drops" are pretty common. 因此网络“下降”非常普遍。
  • Backend database is SqlServer. 后端数据库是SqlServer。
  • There can be upward of 100 computers simultaneously connected at a time. 一次可以同时连接100台计算机。 When the server gets a new connection (TCPServer.OnConnect) I instantiate my own object containing it own SqlServer database connection. 当服务器获得新连接(TCPServer.OnConnect)时,我实例化我自己的包含它自己的SqlServer数据库连接的对象。 When tcp connections are dropped I in turn free these objects (and associated database connection). 当删除tcp连接时,我依次释放这些对象(以及相关的数据库连接)。
  • Client application have a TTimer built into them. 客户端应用程序内置了TTimer。 They routinely send heartbeats to the server. 他们经常将心跳发送到服务器。 And if they "drop"/"lose" their connection they automatically establish a new connection once the network is back. 如果他们“丢弃”/“丢失”他们的连接,他们会在网络恢复后自动建立新连接。

Anyone have any suggestions on the best approach/architecture here? 有人对这里最好的方法/架构有任何建议吗?
I presume the Indy component would work, but at the same time feel I am "reinventing the wheel" with respect to managing the connections. 我认为Indy组件可以工作,但同时感觉我在管理连接方面“重新发明轮子”。

Three component sets I am aware of that will take care of the nitty gritty technical aspects of client server applications for you: 我知道的三个组件集将为您处理客户端服务器应用程序的细节技术方面:

You may have to rework your applications to take advantage of the way these component sets work, but assuming you have properly separated layers that shouldn't be too much of a hassle and will buy you the advantage of well tested and widely used code for your client server work. 您可能必须重新编写应用程序以利用这些组件集的工作方式,但假设您已经正确分离了不应该太麻烦的层,并且会为您提供经过充分测试和广泛使用的代码的优势客户服务器工作。

If you want some light TCP/IP components, take a look at our SynCrtSock unit. 如果您需要一些轻型TCP / IP组件,请查看我们的SynCrtSock单元。

You'll find low-level classes to create IP Client and Servers. 您将找到用于创建IP客户端和服务器的低级类。 We implemented both TCP/IP and UDP/IP in one of our applications. 我们在其中一个应用程序中实现了TCP / IP和UDP / IP。

There is also a THttpServer class, which implement a HTTP/1.1 server. 还有一个THttpServer类,它实现了一个HTTP / 1.1服务器。 Therefore it follows the HTTP/1.1 connection management. 因此它遵循HTTP / 1.1连接管理。 There is also an optional compression, and using HTTP/1.1 on a port other than 80 is not a bad idea. 还有一个可选的压缩,在80以外的端口上使用HTTP / 1.1并不是一个坏主意。 And what is good with HTTP/1.1 is that it can pass through firewalls, and can be easily be VPNed or hosted on another HTTP server (like IIS or Apache) with a proxy. 而HTTP / 1.1的优点在于它可以通过防火墙,并且可以通过代理轻松地在另一个HTTP服务器(如IIS或Apache)上进行VPN或托管。 There is even a FastCGI class, if you need such a server under a linux-based solution. 如果您在基于Linux的解决方案下需要这样的服务器,甚至还有一个FastCGI类。 Of course, a THttpClientSocket class does the same on the client class. 当然,THttpClientSocket类在客户端类上也是如此。

We use these classes to add HTTP/1.1 connection to our Open Source SQLite3 RESTful framework - http://synopse.info/forum/viewforum.php?id=2 我们使用这些类将HTTP / 1.1连接添加到我们的开源SQLite3 RESTful框架 - http://synopse.info/forum/viewforum.php?id=2

See http://synopse.info/fossil/artifact?name=722e896e3d7aad1fe217b0e2e7903483e66d66d1 for the SynCrtSock unit. 有关SynCrtSock单元的信息,请参见http://synopse.info/fossil/artifact?name=722e896e3d7aad1fe217b0e2e7903483e66d66d1 Open source, work from Delphi 7 to Delphi 2010. 开源,从Delphi 7到Delphi 2010。

Misha Charrett's CSI Application Framework covers pretty much exactly what you're asking for. Misha Charrett的CSI应用框架几乎涵盖了您所要求的内容。

It's an open source Delphi framework that at its heart is a distributed message passing and threading framework that allows XML message passing from both client to server and server to client. 它是一个开源Delphi框架,其核心是分布式消息传递和线程框架,允许从客户端到服务器和服务器到客户端的XML消息传递。

It can handle disconnections/reconnections, high client numbers and there's an optional virtual database library that will handle SQL server (or you could just use same SQL Server access you're using now). 它可以处理断开连接/重新连接,高客户端数量以及可以处理SQL服务器的可选虚拟数据库(或者您可以使用现在正在使用的相同SQL Server访问)。

It's not particularly well known yet but I can tell you that it's been actively developed over the last few years and that the author Misha is very keen to assist anyone who's interested in using it in their application. 它还不是特别有名,但我可以告诉你,它在过去几年里一直在积极开发,作者Misha非常热衷于帮助那些有兴趣在他们的应用程序中使用它的人。

Well, it would probably require a complete rewrite of much of your C/S code, but instead of using the Indy components, you could try to use a COM+ solution instead. 好吧,它可能需要完全重写你的大部分C / S代码,但不是使用Indy组件,你可以尝试使用COM +解决方案。 Basically, you would create a COM+ component that will be installed on the server and your client applications will connect to this client and call the functions of this component directly. 基本上,您将创建一个将安装在服务器上的COM +组件,您的客户端应用程序将连接到此客户端并直接调用此组件的功能。 It will have transaction management which will be handled by Windows itself and the same is true about handling transactions. 它将具有将由Windows本身处理的事务管理,并且处理事务也是如此。 It's also technically possible to create events, which would allow the server to do callbacks to the client, although that would make things a bit more complicated. 技术上也可以创建事件,这将允许服务器对客户端进行回调,尽管这会使事情变得复杂一些。
I don't think this solution would work out for you, though, unless you have a lot of experience with COM development in Windows and/or you're brave enough to try something different. 我不认为这个解决方案对您有用,除非您在Windows中有很多COM开发经验和/或您有足够的勇气去尝试不同的东西。
In the past, I had a similar problem where hundreds of clients had to connect to a single server, doing all kinds of database transactions. 在过去,我遇到了类似的问题,数百个客户端必须连接到单个服务器,执行各种数据库事务。 It has a steep learning curve but me and my team managed to get things working and once we understood the technique, it resulted in a very stable and reliable solution which did manage to have up to 500 users simultaneously doing updates and other actions in a one-time extreme stress-test. 它有一个陡峭的学习曲线,但我和我的团队成功地完成了工作,一旦我们理解了这项技术,它就形成了一个非常稳定可靠的解决方案,该解决方案确实可以让多达500名用户同时进行更新和其他操作。 - 极端压力测试。 But again, the learning curse is steep, so it might not be the solution you're looking for. 但同样,学习诅咒是陡峭的,所以它可能不是你正在寻找的解决方案。
(Still, COM+ will use a lot of functionality that's build-in into Windows, like transaction management, database pooling and whatever more.) (尽管如此,COM +将使用许多内置于Windows中的功能,如事务管理,数据库池等等。)

If you use Indy each connection will equal a thread. 如果你使用Indy,每个连接将等于一个线程。

Anyway, I suggest for connecting to MSSQL to use SDAC from Devart http://www.devart.com/sdac/ and for the connection layer to use HPScktSrvr based on I/O Completion Port from http://www.torry.net/authorsmore.php?id=7131 (I don't know though what changes it will need for TThread changes in newer VCL). 无论如何,我建议连接到MSSQL以使用Devart http://www.devart.com/sdac/中的 SDAC,并建议连接层使用基于I / O完成端口的HPScktSrvr来自http://www.torry.net /authorsmore.php?id=7131 (我不知道在更新的VCL中,TThread更改需要进行哪些更改)。 You build your client class arround THPServerClient, you set your new class as the server ClientClass and the framework will create automatically new clients for you. 您可以在THPServerClient中构建客户端类,将新类设置为服务器ClientClass,框架将自动为您创建新客户端。

您可能还想看看ICS / Midware组合: http ://www.overbyte.be/

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

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