Message Routing Context Variables

The following table lists the predefined context variables related to message routing.
gateway90
The following table lists the predefined context variables related to message routing.
Variable
Description
${httpRouting.latency}
Returns the amount of time it took, in milliseconds, to send a request to its downstream endpoint and receive a response back.
This variable is only available after a message has been routed.
${httpRouting.reasonCode}
Returns one of the following reason codes when the HTTP routing fails:
  • -1 (Host Not Found):
    The Server referenced in the URL (for example, nonexistentServer.l7tech.com) cannot be reached. This code can be returned if either the host does not exist or the host is simply down.
  • -2 (Bad URL):
    The URL is incorrect. This could be caused by an incorrect character such as "#".
  • -3 (Connection timeout):
    An initial message was sent to the URL but no response was received before the connection timeout expired. The connection timeout value is defined in the assertion properties.
  • -4 (Read timeout):
    One of packets being received from the URL took longer than the read timeout value to be received. The read timeout value is defined in the assertion properties.
  • -5 (Undefined):
    An unknown type of error has occurred.
When the HTTP routing succeeds, this variable returns the HTTP status, which is often the same as
${response.http.status}
.
${httpRouting.url}
Returns the Protected Service URL from the last routing assertion. This variable should be used after a routing assertion.
When used without a suffix, the entire URL is returned. When used with one of the following optional suffixes, only that part of the URL is returned:
  • .file
  • .fragment
  • .host
  • .path
  • .port
  • .protocol
  • .query
Examples:
${httpRouting.url}
returns the entire Protected Service URL
${httpRouting.url.host}
returns only the host name portion of the URL
The
.file
and 
.
path suffixes usually return the same values.
${rawtcp.reasonCode}
Sets the numeric value of the reason codes which are set regardless of the routing outcome. Below are the codes.
  • 0 (Success Route):
    Successfully routed.
  • -1 (Host Not Found):
    The server cannot be reached. This code is returned if either the host does not exist or the host is simply down.
  • -2 (Connection refused):
    The server does not accept the connection. An incorrect port number may have been used.
  • -3 (Socket timeout):
    No response was received before the connection timeout expired.
  • -4 (Data size limit exceeded):
    The message size has exceeded the data size limit.
  • -5 (Undefined):
    An unknown type of error has occurred.
This variable returns a value only after the HTTP routing.
${request.authorized}  
Returns "true" if one of the following conditions apply, otherwise returns "false":
  • ${request.completed} is true
  • a routing assertion was attemped and failed
  • a routing assertion completed with an error HTTP status
${request.completed}
Returns "true" if the service policy succeeded and routing completed successfully (or was absent from the policy); otherwise, returns "false".
${request.elapsedTime}
Returns the amount of time, in milliseconds, between receiving the request and the time the assertion that uses the variable is executed.
${request.routingTotalTime}
Returns the current cumulative time spend inside routing assertions since the request was received by the Gateway and the time the assertion that uses the variable is executed.
${routingStatus}
Returns the routing status:
  • None (-1):
    The policy contains no routing assertion or the routing assertion was never reached.
  • Attempted (0):
    The routing service was reached, but the message could not be routed successfully.
  • Routed (1):
    The routing assertion was able to successfully route the message.