ASTA Messaging


 

ASTA was designed to be used by Delphi database application developers using skill sets they already possess. ASTA uses TCP/IP for it's transport and contains an easy to use messaging system.

 

ASTA uses non-blocking event driven sockets as it's underlying transport. These sockets are by their nature asyncronous. This means that a message sent by one method does not wait for any response from a server and if a response does come it will fire an event. So if you send something here, when you get a response it will be over there. ASTA was designed that you would not have to deal with foolishness such as this.

 

Both the AstaServerSocket and AstaClientSocket have easy to use messaging calls. You can send a string or a stream with SendCodedMessage or SendCodedStream.

 

Here is the way the ASTAClientSocket can be used:

 

procedure SendCodedMessage(Msgid: Integer; Msg: string);
procedure SendCodedStream(MsgID: Integer; MS: TMemoryStream);

 

AstaClientSocket1.SendCodedMessage(1000, 'Hello World');

 

 

Then on the server you would just code the AstaServerSocket.OnCodedMessage like this:

 

procedure TForm1.AstaServerSocket1CodedMessage(Sender: TObject;

  ClientSocket: TCustomWinSocket; MsgID: Integer; Msg: string);

begin

  case Msgid of

   1000: AstaServerSocket1.SendCodedMessage(ClientSocket, 1001,
           'Hello back to you!');

  end;

end;

 

When we built ASTA there were times of course that we wanted to send other kinds of data than strings and streams so we created the TAstaParamList. The TAstaParamList is just like a TParamList that you are familiar with on the TQuery component but it is fully streamable. It also can contain datasets, any kind of binaries and even other ParamLists. So once we created the TAstaParamList and the call procedure SendCodedParamList(Msgid: Integer; Params: TAstaParamList) we pretty much could transport anything back and forth between servers and clients (and client to client also btw) easily.

 

But, you say, in the above examples we send in one place and receive in anevent and you told us that you saved us from that. AstaClientsockets have a call of SendGetCodedParamList which sends a TAstaParamList and also waits until the server sends back a response. This allows you to write procedural code rather than event driven code.

 

var

  P1, P2: TAstaParamlist;

begin

  P1 := TAstaParamList.Create;

  try

    P1.FastAdd('Hello World');

    P1.FastAdd(Now);

    P1.FastAdd(4.333);

    P2 := AstaClientsocket1.SendGetcodedParamList(1010, P1);

    //Do something with the P2 ParamList that is returned

    //from the function result

  finally

    P1.Free;

    P2.Free;

  end;

 end;

 

ASTA users have thought of all kinds of ways to use ASTA messaging from taking fairly static queries and executing and compressing them on ASTA servers to be sent out using ASTA messaging, to controlling remote servers, to getting back performance information form servers, to sending faxes.

 

Once you have a middle tier, there is a complete world that opens up of new possibilities.

 

See also More on ASTA Messaging

 



ASTA Overview