ePages 7.25.0 - 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
BroadcastCacheUpdate
SynchronizeCache

Functions

BroadcastCacheUpdate
SynchronizeCache
_GetMessageCenterForPool
_GetMessageCenterForPool
broadcastUpdateCacheRequest
close
connect
new
poolName
priority
request
sendFinishRequest
sendIdleRequest
sendInitialFreeRequest
sendMonitorRequest
sendUpdateCacheRequest
sendWorkingRequest
verifyPool

BroadcastCacheUpdate

Sends information about database changes to all message centers.

Syntax
BroadcastCacheUpdate($Database, $hTouched);
Input
$Database (string)
top-level cache key
$hTouched (string)
updated values

SynchronizeCache

Sends information about database changes to the message centers that belong to the pools that are affected by these changes.

Syntax
SynchronizeCache();

_GetMessageCenterForPool

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

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

_GetMessageCenterForPool

Returns a list of all active message centers.

Syntax
$aMessageCenters = _GetMessageCentersForAllPools();
Return
$aMessageCenters (ref.object)
list of MessageCenter objects

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)
updated values

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,
    PoolName         => $PoolName,
    Priority         => $Priority,
);
Example
my $MessageCenter = DE_EPAGES::WebInterface::API::MessageCenter->new(
    AppServerAddress => '127.0.0.1',
    AppServerPort    => '10048',
    PoolName         => 'DefaultPool',
    Priority         => 0,
);
$MessageCenter->connect;
$MessageCenter->sendInitialFreeRequest;
$MessageCenter->sendFinishRequest; # or $MessageCenter->close;
Input
%options (hash)

  • AppServerAddress - application server ip address - string
  • AppServerPort - application server port - int
  • PoolName - (optional; default=DefaultPool) application server pool name - string
  • Priority - (optional; default=0) priority within the pool - int
Return
$MessageCenter (DE_EPAGES::WebInterface::API::MessageCenter)
MessageCenter object

poolName

returns the application server pool name

Syntax
$PoolName = $MessageCenter->poolName;
Return
$PoolName (string)
application server pool name

priority

returns the application server priority

Syntax
$Priority = $MessageCenter->priority;
Return
$Priority (int)
application server priority

request

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

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

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. If the request router connection is no longer available, try to connect to the secondary request router or wait until the primary is up again. Periodically tries to re-connect to the primary request router.

Syntax
$MessageCenter->sendIdleRequest;

sendInitialFreeRequest

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

Syntax
$MessageCenter->sendInitialFreeRequest;

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;

sendUpdateCacheRequest

Reports that a script has changed data.

Syntax
$MessageCenter->sendUpdateCacheRequest($hCacheUpdate);
Input
$hTouched (ref.hash or '1')
touched caches (1=full cache reset)

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;