Andreano Lanusse

Tiburon - more about DataSnap

DataSnap is one of the big features in Tiburon. I’m pretty sure you will be surprised. Steve Shaughnessy started to talk about the new DataSnap.

The new DataSnap is completely independent from COM/DCOM and takes advantage of the DBX Framework. Basically you will transfer information between client and server, using the DBX Framework data types is very easy. So you are be able to execute server methods through the DataSet, and manipulating the returns as DBXReader and ClientDataSet.

Building a Server Side

To build a new DataSnap Server application, you basically need three components.

  • DSServer - Server Component, control the server connection allowing to handle thought the events onConnect, onDisconnect, onError activities on the server.
  • DSTCPServerTransport - Component responsible to transfer the information between client and server thought the port specified as a property. Also you can define the buffer kb size.
  • DSServerClass - Register the server methods to the client.

But, how and what can I expose to the DataSnap Client?

All public methods from any class descendent of TPersistence class could be exposed, since the class contain the compile directive {$MethodInfo ON} and is registered by DSServerClass.

Yes, it works for remote data module.

Below an example, a class exposed in my DataSnap server, contain 3 public methods.

DataSnap - Server methods

Client Side

Let’s talk about the client side. How to connect and execute methods on the server?

The client side connection is based on DBXClient, which means you just need the SQLConnection(dbExpress), define the host name, port and DBXClient driver.

Using DBXClient as the driver you will take advantage of the entire DBX Framework, for example transfer DBXReader between client and server is very easy.

There are many ways to execute the methods exposed on the server, below are some examples using the methods from figure 1.

Executing methods through SqlServerMethod component

One way to execute the methods on the server is using the new SqlServerMethod component, this component inherits from CustomSQLDataSet, which means you will be able to execute server side methods using a DataSet, input/output parameters will be represented by Params property.

DataSnap Client side

 Executing methods through SQLDataSet component

A new CommandType named DataSnap.ServerMethods was added to the SQLDataSet component, which allows you to execute server side methods, returning DBXReader allows you to have bi-directional cursor through the ClientDataSet.

This is a small introduction about things you can do using the new DataSnap. Stay tuned we will bring more details and examples about DataSnap.

Posted by Andreano Lanusse on July 21st, 2008 under Delphi, English |



12 Responses to “Tiburon - more about DataSnap”

  1. Chuck Says:

    Hi Andreano,

    >The new DataSnap is completely independent from COM/DCOM and takes advantage of the DBX Framework

    Re: It is true that TRemoteDataModule was based on COM/DCOM, but only internally. One could connect to remotedatamodules via, let’s say borland connection server, which made MIDAS (that’s the initial name of DataSnap) completely COM/DCOM independent ALREADY. On the other hand, one was able to deal with any kinds of DataSet descendents inside a RemoteDataModule. It would be super humble to tide MIDAS to DBExpress… What would have been useful is to implement true MIDAS callbacks, a mechanism to notify all the clients/subscribers to a MIDAS server of a certain event, triggered/fired/raised form the server! Also, it would have been useful to add full extensibility model to the "resolver".

    *** I did not see any of these features advertised by Mr . Shaughnessy. Which I suspect is one of the reason most real life clients decided to use alternative / 3rd party connectivity and distributivity subsystems. Since you seam to have something to do with real life projects, please ask Steve about these features I mentioned in here (other technologies, e.g. ASTA provide this functionality for years, same about the .NET remoteability, etc). It would be nice if Embarcadero put some order / made some sense of what is currently happening in their Database R&D (talking about codegear)

    What do you think?

    PS
    Would it be so difficult if you folks (team b, you name it) made sure that the posted code snippets made any sense, before they are posted? In the last post, Steve is allocating 3 objects inside a try finally and then uses FreeAndNil against local variables. At least to me (as a super veteran delphi/tp engineer, this makes very little sense (it’s horrible, by any means)). If not, at least give Steve some technical feedback… before he goes public…

    Regards,
    Chuck

  2. Andreano Lanusse Says:

    Chuck, definitely MIDAS callbacks and notification system are great features. Steve Shaughnessy are open for ideas and suggestions.

    The DBX 5 and DataSnao in Delphi 2009 has a lot of work, one of the most important is the open architecture to provide capability to connect php, java, .net, etc.. clients to DataSnap Server.

    The update in DataSnap is just the beginner.

  3. TOndrej Says:

    Chuck,
    IMHO, the try..finally usage is perfectly fine. If you think about it it’s the correct way to ensure that all three local variables will get released from memory in case of an exception within the try..finally block.
    Of course, the alternative would be to use three nested try..finally blocks.
    But I use the above technique myself and find it readable, clear to understand and useful to avoid too much indentation. Just my 2c.

  4. Luigi D. Sandon Says:

    I really hoped to see a real improvements to DataSnap/MIDAS, and get rid of DCOM/COM - but it looks you got the wrong way again - what the hell means to use a "SQL"Connection, "SQL"ServerMethod to call a remote method??? Passing parameters in a "SQL bind" way? Awful!!!!

    Why the communication framework got based on a database technology and not the other way round??? RMI is not procedural SQL!!!

  5. Andreano Lanusse Says:

    Hi Luigi,

    Let me clarify, you are off from COM with the new DataSnap. The communication is based on TCP/IP and use the DBXClient as driver, which allow other technologies/language to connect on DataSnap servers.

    As I wrote, there are many ways to execute the server methods, SqlServerMethod is just one way to execute the server methods..

    One example, if you have a DataSnap server in .NET, VCL and DBX Framerwork together will provide a transparent data type mapping for the client side.

  6. Chuck Says:

    >Steve Shaughnessy is open for ideas and suggestions.

    I’ve noticed… Very open! It would nice if he had a clue about Object Pascal language, VCL and database technoloigies. But then again, maybe I am asking too much… Right?

    >the try..finally usage is perfectly fine

    After explicitly nil-ing the 3 local vars, it’s still weird, but at least is works in all cases. To allocate in the try branch of a try finally is definitely a no way to go (some people do, but then again, some people use visual basic… free country). To FreeAndNil local variables shows little knowledge about RTL (and why not VCL). But then again, this is my $.02 as well (what do I know, I’m just a delphi newbie… :-)

  7. maurice Says:

    since new datasnap is based on indy 10, that means it cannot work asynchronously (indy is a poor/entry level package, kinda like a poor man solution). codegear architects could have afforded to use raw win-sockets, if they wanted to, are there any of them left in the building?
    from what i remember, the whole design of midas.dll is biased towards client dataset compressed deltas marshaled back and forth… midas was not developed in borland but rather purchased and guys like shaughnessy (with a java / managed code background) are very unlikely to ever enteriely redesign midas, in a completely asynchronous manner. chuck mentioned about midas callbacks. well, they had several opportunities to actually implement midas callbacks (i know so from members of the previous database team (ramesh, wigley, marinescu) but the management always denied a full midas redesigned, major improvements in dbaware controls, a full set of wizards, to enhance the ide interaction and basically, all together to inject some innovation into a product which (at least from the database point of view) did not get ANY fundamental improvements since eary 2000(s). the good news is that delphi (and bcb) rock and they seem to have plenty of excellent 3rd party database (and multi-tier) components. chuck mentioned something about asta, great example!

    bottom line, with new management (embarcadero), hopefully, they will improve the amount of innovation which goes into the database subsystem, by hiring people with:

    1. true / hands on experience in building real life database apps
    2. strong object pascal and c++ skills (not java / c# backgrounders)
    3. strong component design expertize, with true / real life libraries in their resume (currently, the team, if any left, has comprehensive server side skills, obviously weak for most delphi client side purpose)
    4. strong innovative ideas, borne from real life situations (practice). i do not know much about the present team (have they been at least once, for few hours, faced with a true database design situation, client side, normalization ?) - from the old / ex database team, we do know (here in germany) that marinescu did have these hands on skills… what happened with these guys? they vanished?

    anyway, the great news (and our best hopes) is that now, when embarcadero seems to be so database related, they will know bit from byte and take the right decisions in the database area, do the right thing, hire the right people, in order to resurrect delphi (phoenix bird style) to what it was by the time of bde, full state for client side (datasets) and get read of theoretical employees, or simply reuse them on what they know best…

    good luck embarcadero, have to run now,
    maurice

  8. Luigi D. Sandon Says:

    What’s .NET?

  9. Juan Carlos Porras B Says:

    I Hope don’t forget ISAPI SOAP servers and TSOAPConnections. This is a powerfull approach to "SMART Clients" paradigm. Delphi 2006 and Delphi 2007 are the best tool to build it.

  10. Sip from the Firehose : Delphi 2009 and C++Builder 2009 Live Webinars with David I starting tomorrow, August 13 Says:

    [...] Tiburon - more about DataSnap   http://blogs.codegear.com/andreanolanusse/2008/07/21/tiburon-more-about-datasnap/ [...]

  11. Paweł Głowacki : Delphi 2009 Online Resources Says:

    [...] Andreano Lanusse blog post: Tiburon - more about DataSnap [...]

  12. LAW LKL Says:

    I am new to C++ Builder 2009 Datasnap.
    I am seeing many example of DataSnap in Delphi only.
    I can see there is a little different in C++, for instance, no ServerDataModule in C++.
    Could you replicate the Delphi example into C++?

    Thanks.

Leave a Comment

Server Response from: blogs2.codegear.com