Middleware Strategies

Middleware, the most complex tier, serves multiple servers and clients. A middleware application usually is initiated upon the first linkage request from a client, but can be available constantly and “listening.” There are critical sections and other locking issues to consider, and these applications must provide full client protection if a service terminates. A middleware application is implemented using connection libraries, as there is no solution for implementing middleware using client and server libraries combined.

Connection Libraries

The program requires two connection block TYPE declarations: one for library objects making up the client interface and one for library objects making up the server interface. The middleware application should include a LIBRARY interface declaration of each connection library type and a READYCL statement for the library interface to clients. How client requests are routed to servers depends on the type of the service. Routing is determined on a session basis or on a per-call basis. For session-based connections, the change procedure for the client interface initiates the server connection.

Example

The following is an example of two ALGOL connection block TYPE declarations:

TYPE CONNECTION BLOCK SERVICETYPE;
	BEGIN
	INTEGER MY_SERVICE_INDEX; %% Set up in CHANGE
	PROCEDURE REQUEST (BUF);
		ARRAY BUF [*];
		PENDING;
	EXPORT REQUEST;
	END SERVICETYPE;

TYPE CONNECTION BLOCK SERVERTYPE;
	BEGIN
	PROCEDURE REQUEST (BUF);
		ARRAY BUF [*];
		IMPORTED;
	END SERVICETYPE;

SERVICETYPE SINGLE LIBRARY SERVICE
	(LIBACCES = BYFUNCTION,
	FUNCTIONNAME = “SERVICESUPPORT.”);

SERVICETYPE LIBRARY SERVERS;

PROCEDURE SERVICETYPE.REQUEST (BUF);
	ARRAY BUF [*];
	BEGIN
	SERVERS [MY_SERVICE_INDEX].REQUEST (BUF);
	END REQUEST;

READYCL (SERVICE);

Linkage Status Control

A CHANGE procedure is required for each library to allow applications to terminate a delinked connection properly. There is no other way to be notified of clients linking to or delinking from your program as it happens or of servers that have delinked and thus become unavailable while your program is using them. Any exported functions that require guaranteed cleanup should use EXCEPTION procedures. This is typical for any locking protocol. No other safe mechanism is guaranteed to be invoked in all cases. The TRY mechanism cannot be invoked for a termination related to a delinkage of the service that is being protected by a TRY statement. If absolute guarantees of cleanup are necessary, an unsafe mechanism should be used, such as a protected EXCEPTION procedure.