简体   繁体   中英

What diference between access Mule ESB variable with flowVars.page or flowVars['page']

I build a api using Mule ESB, and when I deployed it on production env (redhat). a bug appeared.

I have a uri parameter "page" http://localhost:8081/api/assets/33/annotations?page=0 .

On api I capture that query parameter into a variable <set-variable variableName="page" value="#[header:INBOUND:page?]" doc:name="page"/>

And after that I try to capture it the flow. But if I capture using #[flowVar.page] some times its value is null even if ?page=0 .

Now if I try to capture that same variable 'page' using #[flowVars['page']] , never it comes null .

My entire flow is

<flow name="get:/assets/{assetsId}/annotations:api-config" initialState="started">

     <set-variable variableName="page" value="#[header:INBOUND:page?]" doc:name="page"/>

    <jdbc:outbound-endpoint exchange-pattern="request-response" connector-ref="tool_de_anotacao_JDBC" queryKey="get annotations" queryTimeout="-1" doc:name="Database" mimeType="application/json" disableTransportTransformer="true">
        <jdbc:transaction action="ALWAYS_BEGIN"/>
        <jdbc:query key="get annotations" value="select  content from tool.tasset_annotation 
where 1 = 1 and assetId = cast(#[flowVars.assetsId] as text)
    and CASE WHEN #[flowVars.containsKey('page')] THEN  
        page = cast(#[flowVars['page']] as integer ) ELSE
            1 = 1 END order by id desc; 

   "/>

    </jdbc:outbound-endpoint>
    <object-to-string-transformer doc:name="Object to String"/>
    <scripting:component doc:name="Groovy">
        <scripting:script engine="Groovy"><![CDATA[payload = payload.replaceAll("content=","\"content\":");]]></scripting:script>
    </scripting:component>
    <message-properties-transformer mimeType="application/json" doc:name="Message Properties"/>

</flow>

Is that any bug or am I doing some thing wrong?

I couldn't replay that bug in my windows env,

Thanks a lot for your help.

Regards, Valter Gomes

Both syntax are valid ways of accessing map data. MEL is based on MVEL. More info on property navigation here: http://mvel.codehaus.org/MVEL+2.0+Property+Navigation#MVEL2.0PropertyNavigation-MapAccess

One thing that may help is changing the way you set the variable in the first place. You are using deprecated syntax. Try:

<set-variable variableName="page" value="#[message.inboundProperties.?page]" doc:name="page"/>

This appears to be an issue that's fixed in 3.5.3:

https://www.mulesoft.org/jira/browse/MULE-7611

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM