Pergunta

I am storing poll frequency in a properties file in units of seconds. But the frequency attribute of "poll" component in Mule expects the frequency to be in milliseconds. How can I perform multiplication operation here? The below two does not seem to be working:

(1) <poll frequency="${GiantsNew.poll*1000}">
(2) <poll frequency="${GiantsNew.poll}*1000">

Thanks in advance!

Foi útil?

Solução

I'm sorry Mule doesn't support SpEL in the frequency attribute so I had to build the horrible contraption shown below to implement your requirement using only configuration elements.

You could also create a custom class to parse the initial properties bean instead of using the MethodInvokingFactoryBean as I'm doing below.

<spring:beans>
    <util:properties id="properties" location="classpath:appProperties.properties" />
    <spring:bean id="giantsNewProperty"
        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
        p:targetObject-ref="properties" p:targetMethod="setProperty">
        <spring:property name="arguments">
            <spring:list>
                <spring:value>GiantsNewComputedPoll</spring:value>
                <spring:value>#{ T(java.lang.Integer).valueOf(properties.getProperty("GiantsNew.poll")) * 5 }</spring:value>
            </spring:list>
        </spring:property>
    </spring:bean>

    <spring:bean id="computedProperties" factory-bean="properties"
        factory-method="clone" depends-on="giantsNewProperty" />

    <context:property-placeholder
        properties-ref="computedProperties" />
</spring:beans>

...

<poll frequency="${GiantsNewComputedPoll}">
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top