1

I have multiple endpoints for different vendor's and we are differentiating it based on the userId for similar service operation and routing calls accordingly.

mule-app.properties

userIds=123,124,125

123.service.uri=http://google.com

124.service.url=http://yahoo.com

Can someone tell if there is a way to dynamically refer property using MEL and flowVariable holding userId value?

<flow name="test">
<http:listener config-ref="mylistenerconfig" path="test" doc:name="Request Listener" />

<set-variable variableName="userId" value="#[message.inboundProperties.userId]" />
<set-variable variableName="userServiceUri" value="${flowVars['userId'].service.uri}" />

<logger level="INFO" message="******* serviceUri=#[userServiceUri] ****" />

</flow>

I tried directly referring that value from message.inboundProperties.userId, referring it using a seperate variable - nothing works. Can someone suggest on how to achieve this?

Rama Kesara
  • 94
  • 1
  • 7

1 Answers1

1

Load the properties files with Spring:

<util:properties id="muleAppProps"
    location="classpath*:mule-app.properties" />

Then you can dynamically refer to values in it with:

#[app.registry.muleAppProps[userId + '.service.uri']]

Assuming userId is a flow var that contains a value like "123"

David Dossot
  • 33,403
  • 4
  • 38
  • 72