Recent

Author Topic: N-tier multiuser application development  (Read 39525 times)

JD

  • Hero Member
  • *****
  • Posts: 1848
N-tier multiuser application development
« on: August 10, 2010, 06:15:41 pm »
I'm working on the development of a multiuser application using a 3 tier design - a rich client, an application server & a database backend. I have the following options:

a) Build everything in Lazarus

    Client: Lazarus Indy application
    Application Server: Custom Lazarus Indy application
    Database backend: Firebird/PostgreSQL

    The client side could use the TMemDataset to send streamed data using Indy TCP components to the application server which uses Zeos to communicate with the database. The problem is TMemDataset cannot handle master/detail relationships unlike the ClientDataset in Delphi. In addition, passing data over sockets can be blocked by firewalls on the client machine & in addition, sensitive data must be encrypted before sending it over the wire. Encrypting & then decrypting data may have a negative impact on application speed.

b) Build a hybrid solution (I)
    
    Client: A rich client based on Lazarus/Delphi
    Application Server: Apache Geronimo/Glassfish
    Database backend: Firebird/PostgreSQL/JavaDB (also called Apache Derby)
    Database server: Apache Server

    The client side will use Habari ActiveMQ Client to communicate with the application server. The problem is I've never used it before & I'm wondering about the ease of deployment of this solution. It however looks very promising & is one for the future.

c) Build a hybrid solution (II)

    Client: A rich ExtPascal client
    Application Server: Custom Lazarus application
    Database backend: Firebird/PostgreSQL
    Database server: Apache Server

    The client could use CGI or FastCGI to communicate with the application server. The problem here again is that I've never tried this before but ExtPascal (based on ExtJS) looks promising & is also likely to be one for the future.

I'm open to suggestions on the best way to approach this problem. I don't want to use a browser based client side because I don't think they are good at handling data displayed in grids. It is absolutely essential for me that the client resembles a normal desktop application but its inner workings make it a web application. I want the users to have a rich desktop experience.  :D

I know Lazarus does not have anything like DataSnap or WebSnap, so what can I use as alternatives? I've looked at the excellent FreeSpider component but like I said the grid displays are an issue for me.

I'll greatly appreciate your advice, links, articles etc.


« Last Edit: August 11, 2010, 01:35:28 am by JD »
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

jixian.yang

  • Full Member
  • ***
  • Posts: 173
Re: N-tier multiuser application development
« Reply #1 on: August 10, 2010, 06:39:06 pm »
Option A is appreciated.
Use Memorytable of Rxlib with source code modified, we can handle the modified, deleted and inserted data, like delta data in delphi.

With SSL support, Synapse and lNet are popular.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: N-tier multiuser application development
« Reply #2 on: August 10, 2010, 07:04:30 pm »
Use Memorytable of Rxlib with source code modified, we can handle the modified, deleted and inserted data, like delta data in delphi.

I have RxLib but what does "use Memorytable of RxLib with source code modified..." mean? What source code was modified?
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

jixian.yang

  • Full Member
  • ***
  • Posts: 173
Re: N-tier multiuser application development
« Reply #3 on: August 11, 2010, 03:33:33 am »
The modified code can handle old value and new value of record. If just handle the modified, deleted and inserted data, the override InternalOpen, etc can do, not need to modify source code.

The following is the change:

Comparing files RxMemDsEx.pas and RXMEMDS.PAS
***** RxMemDsEx.pas

unit RxMemDsEx;

{$IFNDEF LINUX}
{$I rxl\rx.inc}
{$ELSE}
{$I RXL/rx.inc}
{$ENDIF}

***** RXMEMDS.PAS

unit rxmemds;


{$I rx.inc}

*****

***** RxMemDsEx.pas

uses SysUtils, Classes, Controls, DB, dbutils;
***** RXMEMDS.PAS


uses SysUtils, Classes, Controls, DB, dbutils;
*****

***** RxMemDsEx.pas

{ TRxMemoryData}

***** RXMEMDS.PAS

{ TRxMemoryData }

*****

***** RxMemDsEx.pas

  TRxMemoryData= class(TDataSet)
  private
    FOldBuf:PChar;
    FOnFilterRecordEx: TFilterRecordEvent;
***** RXMEMDS.PAS

  TRxMemoryData = class(TDataSet)
  private
    FOnFilterRecordEx: TFilterRecordEvent;
*****

***** RxMemDsEx.pas
    procedure InternalDelete; override;
    procedure InternalEdit; override;
    procedure InternalPost; override;
***** RXMEMDS.PAS
    procedure InternalDelete; override;
    procedure InternalPost; override;
*****

***** RxMemDsEx.pas
    procedure InternalOpen; override;
    procedure InternalCancel; override;
    procedure OpenCursor(InfoQuery: Boolean); override;
***** RXMEMDS.PAS
    procedure InternalOpen; override;
    procedure OpenCursor(InfoQuery: Boolean); override;
*****

***** RxMemDsEx.pas

{ TRxMemoryData}

***** RXMEMDS.PAS

{ TRxMemoryData }

*****

***** RxMemDsEx.pas
  FRecords := TList.Create;
  FOldBuf := nil;
end;
***** RXMEMDS.PAS
  FRecords := TList.Create;
end;
*****

***** RxMemDsEx.pas

procedure TRxMemoryData.InternalEdit;
begin
     inherited InternalEdit;
     GetMem(FOldBuf,FRecBufSize);
     Move(ActiveBuffer^,FOldBuf^,FRecBufSize);
end;
***** RXMEMDS.PAS

{ Records Management }

function TRxMemoryData.GetCapacity: Integer;
begin
  if FRecords <> nil then Result := FRecords.Capacity
  else Result := 0;
end;
*****

***** RxMemDsEx.pas

{ Records Management }

function TRxMemoryData.GetCapacity: Integer;
begin
  if FRecords <> nil then Result := FRecords.Capacity
  else Result := 0;
end;
***** RXMEMDS.PAS

procedure TRxMemoryData.SetCapacity(Value: Integer);
begin
  if FRecords <> nil then FRecords.Capacity := Value;
end;
*****

***** RxMemDsEx.pas

procedure TRxMemoryData.SetCapacity(Value: Integer);
begin
  if FRecords <> nil then FRecords.Capacity := Value;
end;
***** RXMEMDS.PAS

function TRxMemoryData.AddRecord: TMemoryRecord;
begin
  Result := TMemoryRecord.Create(Self);
end;
*****

***** RxMemDsEx.pas

function TRxMemoryData.AddRecord: TMemoryRecord;
begin
  Result := TMemoryRecord.Create(Self);
end;

function TRxMemoryData.FindRecordID(ID: Integer): TMemoryRecord;
***** RXMEMDS.PAS

function TRxMemoryData.FindRecordID(ID: Integer): TMemoryRecord;
*****

***** RxMemDsEx.pas
    dsCalcFields: RecBuf := CalcBuffer;
    dsOldValue:
    begin
    if FOldBuf=nil then
    RecBuf:=ActiveBuffer
    else
    RecBuf:=FOldBuf;
    end;
    dsFilter: RecBuf := TempBuffer;
***** RXMEMDS.PAS
    dsCalcFields: RecBuf := CalcBuffer;
    dsFilter: RecBuf := TempBuffer;
*****

***** RxMemDsEx.pas
  SetMemoryRecordData(Buffer, Rec.Index);

  GetMem(FOldBuf,FRecBufSize);
  Move(ActiveBuffer^, FOldBuf^, FRecBufSize);
end;
***** RXMEMDS.PAS
  SetMemoryRecordData(Buffer, Rec.Index);
end;
*****

***** RxMemDsEx.pas
  end;
  FreeMem(FOldBuf);
  FOldBuf:=nil;
end;
***** RXMEMDS.PAS
  end;
end;
*****

***** RxMemDsEx.pas
//  OpenCursor(false);
  //           俞疣螯 镱耠?桉镳噔脲龛
{  Fields.Clear;
***** RXMEMDS.PAS
//  OpenCursor(false);
  //           俞疣螯 镱耠?桉镳噔脲龛
{  Fields.Clear;
*****

***** RxMemDsEx.pas

procedure TRxMemoryData.InternalCancel;
begin
     FreeMem(FOldBuf);
     FOldBuf:=nil;
     inherited InternalCancel;
end;
***** RXMEMDS.PAS

procedure TRxMemoryData.InternalHandleException;
begin
  Application.HandleException(Self);
end;
*****

***** RxMemDsEx.pas

procedure TRxMemoryData.InternalHandleException;
begin
  Application.HandleException(Self);
end;
***** RXMEMDS.PAS

procedure TRxMemoryData.InternalInitFieldDefs;
begin
end;
*****

***** RxMemDsEx.pas

procedure TRxMemoryData.InternalInitFieldDefs;
begin
end;
***** RXMEMDS.PAS

function TRxMemoryData.IsCursorOpen: Boolean;
begin
  Result := FActive;
end;
*****

***** RxMemDsEx.pas

function TRxMemoryData.IsCursorOpen: Boolean;
begin
  Result := FActive;
end;

{ Informational }
***** RXMEMDS.PAS

{ Informational }
*****


herux

  • Full Member
  • ***
  • Posts: 102
Re: N-tier multiuser application development
« Reply #4 on: August 11, 2010, 05:03:40 am »
Go to Option
 D. Using http://wiki.freepascal.org/tiOPF, its support HTTP Proxy-Remote.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: N-tier multiuser application development
« Reply #5 on: August 11, 2010, 09:26:30 am »
Go to Option
 D. Using http://wiki.freepascal.org/tiOPF, its support HTTP Proxy-Remote.

Thanks I already know about tiOPF. I skipped it because it is not clear if it works with ZeosLib. I'll take another look at it but having the Zeos option is absolutely important for me.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

herux

  • Full Member
  • ***
  • Posts: 102
Re: N-tier multiuser application development
« Reply #6 on: August 11, 2010, 10:37:14 am »
I use zeoslib in tiopf, and that's ok. you just need a little editing

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: N-tier multiuser application development
« Reply #7 on: August 11, 2010, 11:06:18 am »
I use zeoslib in tiopf, and that's ok. you just need a little editing

What needs to be edited?
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: N-tier multiuser application development
« Reply #8 on: August 13, 2010, 09:54:06 am »
Waiting for inspiration..... :D Anybody there ???
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

herux

  • Full Member
  • ***
  • Posts: 102
Re: N-tier multiuser application development
« Reply #9 on: August 13, 2010, 10:23:41 am »
Quote
What needs to be edited?

create objects from tiopf, use zeosdbo as the data connection.
I think you'll know what needs to be corrected.
just something simple, such as the use of execsql and Open method

herux

  • Full Member
  • ***
  • Posts: 102
Re: N-tier multiuser application development
« Reply #10 on: August 13, 2010, 10:24:58 am »
oh sorry you have to grab the source from svn

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: N-tier multiuser application development
« Reply #11 on: August 13, 2010, 10:57:05 am »
oh sorry you have to grab the source from svn

You're right there because the official release cannot be compiled. I kept getting errors.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: N-tier multiuser application development
« Reply #12 on: August 20, 2010, 05:12:10 am »
So what have you decided to use?

Sandeep

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: N-tier multiuser application development
« Reply #13 on: August 21, 2010, 08:18:48 pm »
So what have you decided to use?

Sandeep

I've decided to proceed this way

1) For small to medium scale projects, I'll adopt a mixture of my option (a) & the tiOPF package as the application server.

2) For larger scale projects, I'll have to use a Java application servers because of freely available reporting tools (BIRT & iReports). This also makes sense because some companies already have them in place & they are proven solutions.

I really like ExtPascal (it looks beautiful) but I'm not too clear about licensing. ExtJS has both an open source license & a commercial license. How does this affect ExtPascal? I'm not too sure.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

bobo

  • Full Member
  • ***
  • Posts: 171
Re: N-tier multiuser application development
« Reply #14 on: September 30, 2010, 01:32:32 am »
Kind of late to join the discussion here, but I am now successfully using ExtJS directly with FPC/Lazarus with the latest fcl-web/fpweb with JSON communication (works with XML too, but XML was a big overhead I did not need), also using Ajax calls from the ExtJS side to call the web server CGI/FCGI actions, also using html templates with fptemplate, etc. All works.

You need to have the latest FPC 2.5.1 SVN sources and the latest Lazarus SVN sources at the moment, but it works nicely.

No licensing issues or anything...
« Last Edit: September 30, 2010, 01:36:04 am by bobo »

 

TinyPortal © 2005-2018