3

I have a spring integration configured to build a url from a property and some variables:

    <int-http:outbound-gateway
            url="${pdf.url}?id={id}&amp;version={version}"
            request-factory="int.http.requestFactory"
            http-method="GET"
            transfer-cookies="false"
            header-mapper="fTokenHeaderMapper"
            expected-response-type="java.lang.String" >
        <int-http:uri-variable name="id" expression="payload.id"/>
        <int-http:uri-variable name="version" expression="payload.version"/>
    </int-http:outbound-gateway>

Now I want to change it so that the server part (pdf.url) could be changed on the fly and not only on startup. To achieve that I have changed from 'url' to 'url-expression' and something like this:

    <int-http:outbound-gateway
            url-expression="@configurationService.getConfiguration('pdf.url')?id={id}&amp;version={version}"
            request-factory="int.http.requestFactory"
            http-method="GET"
            transfer-cookies="false"
            header-mapper="fTokenHeaderMapper"
            expected-response-type="java.lang.String" >
        <int-http:uri-variable name="id" expression="payload.id"/>
        <int-http:uri-variable name="version" expression="payload.version"/>
    </int-http:outbound-gateway>

This line seems to work:

url-expression="@configurationService.getConfiguration('pdf.url')"

But how do I include the variables in a similar way as the first example?

2 Answers 2

2

From the big height I'd move that URI variables part to the configurationService.getConfiguration(), too. It will be more cleaner to read the XML config.

From other side the url-expression is a SpEL runtime expression. So, any its part which should not be executable, must be as literal:

url-expression="@configurationService.getConfiguration('pdf.url') + '?id={id}&amp;version={version}'"
Sign up to request clarification or add additional context in comments.

Comments

0

Your configuration is only read once during startup, so you can't change the value of pdf.url during runtime and expect that it'll change dynamically.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.