![developer4 | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/developer4.jpg?resize=1140%2C694&ssl=1)
The MoniLayerClients sample shows you how to use the FireDAC tracing and monitoring capabilities to show how an application is communicating with a FireDAC monitor client. To this end, the sample uses two different FireDAC monitor clients: FlatFile-client and Remote-client. To use both monitor clients, the sample uses two client link components: the TFDMoniFlatFileClientLink component and the TFDMoniRemoteClientLink component.
Table of Contents
Location
You can find the MoniLayerClients sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
Object PascalDatabaseFireDACSamplesMoni LayerClients
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
How to Use the Sample
- Navigate to the location given above and open
Clients.dproj
. - Press F9 or choose Run > Run.
- Click on the Use Connection Definition combo box and select an option; for example:
EMPLOYEE
. - Select a monitor client.
![Clients | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/10/Clients.png?resize=750%2C450&ssl=1)
Files
File in Delphi | Contains |
---|---|
Clients.dproj Clients.dpr | The project itself. |
fClients.pas fClients.fmx | The main form. |
Implementation
The following steps are needed to implement the sample.
Define the trace / monitor output of a connection definition
Type the following code to set up a connection definition using none, remote or flat file monitoring.
1 2 3 4 5 6 7 8 |
var oConnectionDef: IFDStanConnectionDef; begin oConnectionDef := ... ... <em>// Set up connection def to use none client</em> oConnectionDef.Params.MonitorBy := 'None'; ... |
or
1 2 3 4 |
... <em>// Set up connection def to use Remote client</em> oConnectionDef.MonitorBy := 'Remote' ... |
or
1 2 3 4 |
... <em>// Set up connection def to use Remote client</em> oConnectionDef.Params.MonitorBy := 'FlatFile'; ... |
Output user messages
Use this code to produce custom trace outputs.
1 2 3 4 5 6 7 8 9 10 11 |
var oMoni: IFDMoniClient; begin //... oMoni.Tracing := True; oMoni.Notify(ekVendor, esStart, Self, 'Start monitoring', ['Form', 'frmClients']); oMoni.Notify(ekVendor, esProgress, Self, 'Progress monitoring', ['Form', 'frmClients']); oMoni.Notify(ekVendor, esEnd, Self, 'End monitoring', ['Form', 'frmClients']); oMoni.Notify(ekError, esProgress, Self, 'Error during monitoring', ['Form', 'frmClients']); oMoni.Tracing := False; //... |
Output example
The following image is an example of the trace output produced with a flat file monitor client.
![flatfiletrace-9483616](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/11/FlatFileTrace-9483616.png?w=750&ssl=1)
For more information, please follow the link to the original post:
http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.MoniLayerClients_Sample
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition