How to have RouteRule condition with values from Key Value Maps

Not applicable

I have the following route. It is working perfectly.

<RouteRule name="login-sessions">
    <Condition>(base-action == "login") and (action == "sessions") and (request.verb = "POST")</Condition>
    <TargetEndpoint>default</TargetEndpoint>
</RouteRule>

Note: Here base-action and action are from ExtractVaiables. I'm extracting it from URIPath.

Now I would like to add one more condition from Key Value Maps. i.e. In Key Value Maps, I have created a new key called MigrationComplete and its value is false MigrationComplete: false if the MigrationComplete flag is false it should go to default else it should go to some XYZ endpoint.

<RouteRule name="login-sessions-migration-in-progress">
    <Condition>(base-action == "login") and (action == "sessions") and (request.verb = "POST") and (MigrationComplete = "false")</Condition>
    <TargetEndpoint>default</TargetEndpoint>
</RouteRule>
<RouteRule name="login-sessions-migration-complete">
      <Condition>(base-action == "login") and (action == "sessions") and (request.verb = "POST") and (MigrationComplete = "true")</Condition>
      <TargetEndpoint>XYZ</TargetEndpoint>
 </RouteRule>

MigrationComplete = "false" is not working. How to have RouteRule condition with values from Key Value Maps

1 1 342
1 REPLY 1

The condition looks fine.

Are you sure the MigrationComplete is set the way you think it is set?

One way to check it is to include an AssignMessage policy that simply assigns the value of one variable to another. Like this:

<AssignMessage name='AM-DiagnosticsHelper'> 
  <AssignVariable>
    <Name>dummy</Name>
    <Ref>MigrationComplete</Ref>
  </AssignVariable>
</AssignMessage>

Then, when you turn on tracing, you will see the values read and assigned.

Let me clarify something: are you saying that the condition for MigrationComplete = "true" is working as you expect, but the condition for MigrationComplete = "false" is not working as you expect?

That seems odd, and it suggests that there is an assumption that you are making, that is incorrect.

The MigrationComplete variable - how does it get populated? Is the MigrationComplete is populated via a KVM Read, like this:?

<KeyValueMapOperations name='KVM-1' >
  <Scope>environment</Scope>
  <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
  <Get assignTo='MigrationComplete'>
    <Key>
      <Parameter>migration-complete-key</Parameter>
    </Key>
  </Get>
</KeyValueMapOperations>

if that is the case, then the variable MigrationComplete gets a value if and only if a value is read with that key. It's possible the value will get nothing (null). In which case (MigrationComplete = "false") will evalaute to false.

So maybe what you need is

<Condition>(base-action == "login") and (action == "sessions") and (request.verb = "POST") and (NOT (MigrationComplete = "true"))</Condition>