TsgcWSCircuitBreaker › Methods › RecordMessageError
Server-side hook that records a message failure on ServerKey.
procedure RecordMessageError(const aIP: string; const aException: string = '');
| Name | Type | Description |
|---|---|---|
aIP | const string | Peer IP address of the connection that delivered the failing message. Accepted for logging and future per-IP metrics. |
aException | const string | Optional exception text (ClassName: Message) passed to Classification so server-side business errors can be ignored. |
WebSocket-message flavored failure recorder for server-side self-protection. Delegates to RecordFailure(ServerKey, aException) — the IP parameter is currently informational. Call from the server's OnMessage handler when processing fails so the breaker can trip itself Open if the server is overwhelmed (for example by a burst of malformed messages or a dependent downstream that has fallen over). OnFailureRecorded fires with ServerKey as the key. Returns immediately when Enabled is False.
procedure TForm1.WSServerMessage(Connection: TsgcWSConnection;
const Text: string);
begin
try
HandleMessage(Text);
sgcWSCircuitBreaker1.RecordMessageSuccess(Connection.PeerIP);
except
on E: Exception do
begin
sgcWSCircuitBreaker1.RecordMessageError(Connection.PeerIP,
Format('%s: %s', [E.ClassName, E.Message]));
raise;
end;
end;
end;