Hi,
I am trying to create rules for different routes and target endpoints based on tenants, so that the code below can be replaced with something more dynamic. I have two questions here:
1. How can I read supported tenants and their target endpoints from external file (i.e. file from git or by calling some API)? Is custom code in JS the only way?
2. Is the only way to add route rules dynamically via JS?
<RouteRule name="routeToTenant1"> <Condition>(tenantId = "tenant1")</Condition> <TargetEndpoint>tenant1</TargetEndpoint> </RouteRule> <RouteRule name="routeToTenant2"> <Condition>(tenantId = "tenant2")</Condition> <TargetEndpoint>tenant2</TargetEndpoint> </RouteRule>
Solved! Go to Solution.
1. How can I read supported tenants and their target endpoints from external file (i.e. file from git or by calling some API)? Is custom code in JS the only way?
You could use a service call out if you have an API that can give you the tenants and the target mappings
Custom java callout can also be used if its more complex and you cant get the required data through service callout or JS httpclient
2. Is the only way to add route rules dynamically via JS?
Route rule conditions are preset in the proxy endpoint. Similar to the xml you have posted, the tenantId values tenant1, tenant2 etc are constants and preset.
JS or assign Message policy can be used to set the value of tenantId that you retrieve from the external file/API