ePages 6.10 - DE_EPAGES/WebInterface/API/MessageCenter.pm

Package DE_EPAGES::WebInterface::API::MessageCenter

This module encapsulates all communication between the message center and the application server.

@EXPORT_OK
SynchronizeCache
GetMessageCenterForScripts

Functions

GetMessageCenterForScripts
SynchronizeCache
_request
broadcastUpdateCacheRequest
close
connect
new
sendFinishRequest
sendIdleRequest
sendInitialFreeRequest
sendMonitorRequest
sendPoolChanges
sendPoolReset
sendUpdateCacheRequest
sendWorkingRequest
verifyPool

GetMessageCenterForScripts

Creates a message center object to communicate with the MC/RR.

Syntax
$MessageCenter = GetMessageCenterForScripts($AppServerPoolName, $Tries);
Input
$AppServerPoolName (string)
application server pool (default: 'DefaultPool')
$Tries (integer)
count of tries to connect MC (default: 1)
Return
$MessageCenter (object)
MessageCenter object

SynchronizeCache

Sends information about database changes to the message center.

Syntax
SynchronizeCache($AppServerPoolName);
Input
$AppServerPoolName (string)
application server pool
(optional, default: 'DefaultPool')

_request

sends a request to the message center using the message center protocol.

Syntax
$OutData = $self->_request( $RequestCode, $RequestLine );
$OutData = $self->_request( $RequestCode, $RequestLine, $InData );
Example
$CacheUpdate = $self->_request( MCREQUEST_WORKING, '10.10.10.10:10046', $CacheData );
Input
$RequestCode (integer)
request code
$RequestLine (string)
request header parameters
$InData (string)
request body
Return
$OutData (string)
response body

broadcastUpdateCacheRequest

Reports that a script has changed data. Unlike sendUpdateCacheRequest, this function distributes the data to all pools. This is useful if application servers use cache data from different pools, e.g. shared template byte code.

Syntax
$MessageCenter->broadcastUpdateCacheRequest( $Database, $hTouched );
$MessageCenter->broadcastUpdateCacheRequest( 'Store', { TemplateByteCode => 1 } );
Input
$Database (string)
top-level cache key
$hTouched (string)
top-level cache key

close

Close connection to message center.

Syntax
$MessageCenter->close;

connect

Establishes a connects to the message center at the ip address and port specified in the constructor new.

Syntax
$MessageCenter->connect();
$MessageCenter->connect( $MaxTries );
Example
$MessageCenter->connect( 100 );
Input
$MaxTries (int)
number of connection attempts if the message center cannot
be contacted (optional, default: 1)

new

Creates a new MessageCenter object. Before using any other method you must establish a connection by using the connect method.

Syntax
$MessageCenter = DE_EPAGES::WebInterface::API::MessageCenter->new(
    AppServerAddress => $AppServerAddress,
    AppServerPort    => $AppServerPort,
);
Example
my $MessageCenter = DE_EPAGES::WebInterface::API::MessageCenter->new(
    AppServerAddress => '127.0.0.1',
    AppServerPort    => '10048',
);
$MessageCenter->connect;
$MessageCenter->sendInitialFreeRequest;
$MessageCenter->sendFinishRequest; # or $MessageCenter->close;
Input
$AppServerAddress (string)
application server ip address
$AppServerPort (int)
application server port
Return
$MessageCenter (object)
the new message center

sendFinishRequest

Reports that the application server process terminates itself. The message center communicates to the request router that this application server cannot receive any new requests. The connection to the message center will be closed.

Syntax
$MessageCenter->sendFinishRequest;

sendIdleRequest

Reports that the application server has finished processing the current request and is now idle. The message center communicates to the request router that this application server can now receive a new request.

Syntax
$MessageCenter->sendIdleRequest;

sendInitialFreeRequest

Registers an application server at the message center or change pool assigment.

Syntax
$MessageCenter->sendInitialFreeRequest($PoolName);
Input
$PoolName (string)
new pool name (optional)

sendMonitorRequest

Reports that the application server process will perform a lengthy operation. This information can be used by request router for load balancing.

Syntax
$MessageCenter->sendMonitorRequest;

sendPoolChanges

Reports PoolDB changes to RR.

Syntax
$MessageCenter->sendPoolChanges($TransactionIndex, $aTransactions);
Input
$TransactionIndex (integer)
transaction index
$aTransactions (ref.array.string)
list of SQL statements

sendPoolReset

Forces the Request Router to dismiss the local cache and re-load everything from the shared version of ASPoolDB.

Syntax
$MessageCenter->sendPoolReset;

sendUpdateCacheRequest

Reports that a script has changed data.

Syntax
$MessageCenter->sendUpdateCacheRequest;

sendWorkingRequest

Reports that the application server is now working. The message center communicates to the request router that this application server can not receive new requests.

Syntax
$MessageCenter->sendWorkingRequest;

verifyPool

Looks at pool database if application server is assigned to new pool. Then an initial free request for the new pool will be send.

Syntax
$MessageCenter->verifyPool;
Input
$PoolName (string)
new pool name (optional)