Using Multiple URLS in the Route via HTTP(S) Assertion

Document ID : KB000124179
Last Modified Date : 07/01/2019
Show Technical Document Details
Issue:
We are considering a failover/load balancing implementation strategy via our Gateway policies. Currently, we have a single fragment that sets up context variables that contain the destination URLs. The variable names are multipart and there is only one value for each combination. This fragment is included in all policies that do routing. We can define multiple URLs in Route via HTTP(S) and set the failover strategy or define multiple routes in a routing strategy.

Can you setup a multi-valued context variable with all the possible routes and then tell the assertion to get the values from that context variable?
Environment:
CA API Gateway 9.2+
Resolution:
To select one of the URLs from the multivalued context variable, you'll need to use indexing. Consider the following test case:
==============
1. Set Context Variable Assertion
==============
Variable: chooseHost
Data Type: String
Content-Type: text/xml
Expression: http://host1/rest/test,http://host2/rest/test,http://host3/rest/test
==============
2. Split Variable
==============
Source: chooseHost
Target: gotHost
Split Pattern: ,
==============
3. Route via HTTP(S)
==============
+ Under the Connection Tab
+ Select Use multiple URLs
+ Click [Add] button
${gotHost[0]}
${gotHost[1]}
${gotHost[2]}
+ Failover strategy: Round-Robin (used during testing to confirm all URLs were accessible; any Failover strategy will work)


You cannot specify ${gotHost} under 'Use multiple URls' as a single entry. If you do, all the URLs in the multivalued context variable were read as a string and generate an error like the one below:
************************
2018-11-26T08:58:51.919-0500 WARNING 98079 com.l7tech.common.http.prov.apache.components.HttpComponentsClient: Invalid URI Illegal character in path at index 37: http://host1/rest/test, http://host2/rest/test, http://host3/rest/test
2018-11-26T08:58:51.922-0500 INFO 98079 com.l7tech.server.message: 00000166e3fd440e-2aa6e - Processing request for service: Choose Host [/choosehost]
2018-11-26T08:58:51.922-0500 INFO 98079 com.l7tech.external.assertions.comparison.server.ServerComparisonAssertion: 7101: Comparison did not match: ${request.url.path} is equal to /auth/oauth/v2/authorize (case sensitive)
2018-11-26T08:58:51.922-0500 INFO 98079 com.l7tech.external.assertions.comparison.server.ServerComparisonAssertion: 7101: Comparison did not match: ${request.url.path} is equal to /auth/oauth/v2/token (case sensitive)
2018-11-26T08:58:51.922-0500 WARNING 98079 com.l7tech.server.policy.assertion.ServerHttpRoutingAssertion: 4042: Problem routing to http://host1/rest/test, http://host2/rest/test, http://host3/rest/test. Error msg: Invalid URI http://host1/rest/test, http://host2/rest/test, http://host3/rest/test
2018-11-26T08:58:51.922-0500 WARNING 98079 com.l7tech.server.policy.assertion.ServerHttpRoutingAssertion: 4023: Unable to route to the service after multiple failed attempts

2018-11-26T08:58:51.922-0500 INFO 98079 com.l7tech.external.assertions.comparison.server.ServerComparisonAssertion: 7103: At least one comparison value was null
2018-11-26T08:58:51.922-0500 WARNING 98079 com.l7tech.server.MessageProcessor: 3016: Request routing failed with status 601 (Error in Assertion Processing)
************************