Search Results for

    Show / Hide Table of Contents

    TEcho Class

    The TEcho class groups most of the operations you can perform in a single, helper class. Using this class you will be able to create and register nodes, perform routing, batch loading, push/pull data, etc..

    TEcho class is declared in the Echo.Main unit, and since most of its operations are performed at the local database level, to create a TEcho instance you need to pass an IDBConnectionPool interface that provides connections to the local database. Please refer to the Database Connections topic for more information about database pools.

    uses Echo.Main, 
      Aurelius.Drivers.Base, Aurelius.Drivers.FireDac;
    
    var
      Echo: TEcho;
    {...}
      Echo := TEcho.Create(TDBConnectionFactory.Create(
        function: IDBConnection
        var
          MyDataModule: TMyDataModule;
        begin
          // This example creates a pool using a FireDac connection placed in the 
          // TMyDataModule data module.
          // Please refer to proper topic to learn more about creating connection
          // pools and factories
          MyDataModule := TMyDataModule.Create(nil);
          Result := TFireDacConnectionAdapter.Create(MyDataModule.FDConnection1, MyDataModule);
        end
      );
    

    Once you create a TEcho instance for a local database, you can keep it alive for the whole lifetime of your application, and use its methods and properties to perform the needed operations.

    Methods

    Name Description
    procedure BatchLoad; Loads all the pending incoming batches into the database, using the default TMappingExplorer.
    procedure BatchLoad(Explorer: TMappingExplorer) Loads all the pending incoming batches into the database, using the TMappingExplorer object specified by the Explorer parameter.
    procedure Route(AOnRouteToNode: TEchoRouteToNodeProc = nil) Routes pending changes to all registered nodes.
    function GetNodeManager: IEchoNodeManager Retrieves the IEchoNodeManager interface for managing nodes in local database
    function GetRemoteNode(const AServerUri: string): IEchoRemoteNode Retrieves an IEchoRemoteNode interface representing the remote node accessible through the server specified by the ServerUri parameter.
    function GetRemoteNode(TargetPool: IDBConnectionPool): IEchoRemoteNode Retrieves an IEchoRemoteNode interface representing the remote node accessible through the database connection specified by the TargetPool parameter.

    Properties

    Name Description
    Pool: IDBConnectionPool Contains a reference to the connection pool passed in the constructor method.
    class property Explorer: TMappingExplorer The TMappingExplorer object containing all classes and mappings used by TMS Echo
    PredictiveFallback: Boolean If True, Echo will use predictive fallback to anticipate possible errors in the batch loading and perform the fallback operation before the error happens.

    Events

    Name Description
    OnClientCreate: TProc<TXDataClient> This event is fired whenever a TXDataClient object is created by TMS Echo to perform requests to a XData Server. You can use this event to configure the client (and the Sparkle HTTP Client using TXDataClient.HttpClient property), for example to add authentication, as in the following code.
    Echo1.OnClientCreate :=
      procedure(XClient: TXDataClient)
      begin
        XClient.HttpClient.OnSendingRequest :=
          procedure(Req: THttpRequest)
          begin
            Req.Headers.SetValue('Authorization', 'Bearer ' + AuthToken);
          end;
      end;
    

    Database Connections (Pools)

    TMS Echo normalizes any database connection through the IDBConnectionPool interface. Whenever there is a need to connect to a database, it will get a connection from the pool. Most classes in TMS Echo that need a database connection will ask you to provide a connection pool.

    The process of creating a connection pool is more detailed explained in the topic IDBConnection Pool interface in the TMS XData manual.

    For TMS Echo, it's recommended that you create a pool using the TDBConnectionFactory class, since there is no strong need for pooling mechanism, just creating a connection each time is needed is enough.

    So, for a quick reference, here is an example of how to create the connection (pool) from an existing TFDConnection (FireDac) placed in the data module TMyDataModule:

    uses {...}, Aurelius.Drivers.Base, Aurelius.Drivers.Interfaces,
      Aurelius.Drivers.FireDac;
    
    var
      ConnectionPool: IDBConnectionPool;
    begin
      ConnectionPool := TDBConnectionFactory.Create(
          function: IDBConnection
          var
            MyDataModule: TMyDataModule;
          begin
            // Creates a datamodule which contains a 
            // TFDConnection component that is already configured
            MyDataModule := TMyDataModule.Create(nil);
    
            // The second parameter makes sure the data module will be destroyed
            // when IDBConnection interface is released
            Result := TFireDacConnectionAdapter.Create(MyDataModule.FDConnection1, MyDataModule);
          end
        ));
    end;
    
    In This Article
    Back to top TMS Echo v1.11.3.11
    © 2002 - 2025 tmssoftware.com