Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Creating dynamic target endpoint by tenant and external configuration

nejra
New Member

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 Solved
0 3 437
1 ACCEPTED SOLUTION

@Nejra Husak

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

View solution in original post

3 REPLIES 3