[ Pobierz całość w formacie PDF ]
.For C++Builder 4 DataSnap servers, this isn t present,which means that if you upgrade a C++Builder 4 DataSnap server to C++Builder 5 or6, you must not forget to include a new UpdateRegistry method.If, for any reason,the new DataSnap server doesn t register itself as using the socket communicationprotocol, you can always use the C++Builder 6 socket server (and not the C++Builder4 socket server).In the Connections menu you can specify that you don t wantRegistered Object Only (you want to see unregistered objects as well, as can be seenin Figure 21.1).FIGURE 21.1 Borland socket server looking at registered objects only. 26 0672324806 CH21 12/12/02 2:41 PM Page 819TCP/IP SocketConnection 819This change will not take affect until the socket server is restarted, but then youcan see C++Builder 6 DataSnap servers using the TSocketConnection componentregistered or not.A final new feature regarding the TSocketConnection component has to do with call-backs.TDCOMConnection components always support callbacks, and TWebConnectioncomponents never support callbacks.With a TSocketConnection component you canspecify using the SupportCallbacks property, whether the TSocketConnection compo-nent will marshal calls from the DataSnapServer to the DataSnapClient over an inter-face supplied as a callback.If you don t want to do that, you can set SupportCallbacksto false (it s true by default).Setting it to false has the advantage that you thenneed only Winsock 1 support to deploy your DataSnapClient, whereas otherwise(with SupportCallbacks set to true) you need Winsock 2 or higher.Because Windows95 doesn t include Winsock 2 by default, this means one less deployment problem(believe it or not there are still clients out there using Windows 95).Object BrokerYou ve now seen three possible connection components that exist in C++BuilderEnterprise: TDCOMConnection, TWebConnection, and TSocketConnection all connecting to asingle DataSnap server application.However, sometimes you don t have a singleDataSnap server to connect to, but multiple DataSnap servers.Reasons for havingmultiple DataSnap servers can be diverse, but most often this is done for loadbalancing and failover.If one server goes down, others can take over, and having10 servers all over the world usually results in fewer bottlenecks than having onebig server.Imagine having to determine at the client side which of these DataSnap Servers toconnect to.You d need to know exactly which servers are available (or you mightmiss one maybe the last one that s available at the time) and how to connect tothem.In an ideal world, you wouldn t want all your clients to know about this.Fortunately, DataSnap offers a helpful hand in this case, by means of the conceptcalled Object Brokering.With Object Brokering, you make a connection from the client to a server withoutknowing which server you ll end up with.Each of the three connection componentshas a property called ObjectBroker.This property can be used to connect to a compo-nent derived from TCustomObjectBroker.It will then be responsible for telling theconnection component which server to use (by specifying the ServerName orServerGUID).Note that when you actually use an ObjectBroker, the local values speci-fied for the ServerName and ServerGUID properties will be ignored as far as your appli-cation is concerned; ObjectBroker will supply you with dynamic values at runtime.As an example of how to implement your own Object Brokering techniques,C++Builder Enterprise comes with a TSimpleObjectBroker component (found on theDataSnap tab of the Component Palette). 26 0672324806 CH21 12/12/02 2:41 PM Page 820820 CHAPTER 21 DataSnap Multitier ConnectionsTSimpleObjectBroker itself contains two interesting properties.Servers contains a listof available servers, for each of which you can specify the ComputerName, the Port (211by default), and Enabled.Note that you as a developer must make sure that this list isfilled and maintained properly.If you add a new server or a server goes down, youmust update the list.The second property is LoadBalanced.As the name indicates, this property tries toensure that the servers are load balanced, or at least that a request is balanced amongthe servers.The technique used here is based on a random generator.WhenLoadBalanced is set to true, each connection component will be connected to arandom server from the list.When LoadBalanced is set to false (the default), eachconnection component on the client application will be connected to the first serveron the list [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wpserwis.htw.pl