user1907859
user1907859

Reputation: 574

Using url-expression

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?

Upvotes: 3

Views: 1195

Answers (2)

Wins
Wins

Reputation: 3460

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.

Upvotes: 0

Artem Bilan
Artem Bilan

Reputation: 121177

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}'"

Upvotes: 2

Related Questions