Announcement Announcement Module
No announcement yet.
how to use URI-VARIABLE for port number Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to use URI-VARIABLE for port number

    Goal is to provide a variable port number for the following outbound http gateway.

    <int-http:outbound-gateway id="httpOutboundGateway"
    ... >

    <int-http:uri-variable name="myHost" expression="headers['X-CUSTOM-PROVIDER-HOSTNAME']" />
    <int-http:uri-variable name="myPort" expression="headers['X-CUSTOM-PROVIDER-PORT']" />
    <int-http:uri-variable name="myPath" expression="headers['X-CUSTOM-PROVIDER-PATH']" />
    <int-http:uri-variable name="myQuery" expression="headers['X-CUSTOM-PROVIDER-QUERY']" />


    Three of the four URI-VARIABLES work fine - except myPort.

    Supplied port number is always translated as part of the path (ie http://myHost/myPort/..). Digging into SI v3.1.2.RELEASE code, I find the org.springframework.web.util.UriComponentBuilder class responsible for translating my token URI. The class has a regex pattern for port that looks for digits (PORT_PATTERN = (\\d*) ). Fine if a number is supplied, but it doesn't appear to allow for a variable port number in the form of '{token}'.

    Can I do the port replacement in the URI?


  • #2
    I assume you mean Spring 3.1.2 not SI 3.1.2.

    Spring 3.1 had to make some changes to solve some other issues and this changed the way uris are built.

    In Spring Integration 2.2, we introduced 'url-expression' as an alternative to using 'url' with uri-variables to avoid these kinds of issues.

    Using uri-expression, you can insert your headers in-line, to build up the full URL.

    url-expression="'http//' + headers['X-CUSTOM-PROVIDER-HOSTNAME'] + "':'" + headers['X-CUSTOM-PROVIDER-HOSTNAME'] ... etc
    This is available in Spring Integration 2.2.0, which will be released shortly. 2.2.0.RC3 was released last week; you may find 2.2.0.RELEASE in maven central over the weekend.


    • #3
      life is good

      thanks Gary - the new version & technique did the job. many thanks.