Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12252

Dynamic setting the DESTINATION_OVERRIDE_URL doesn't work on CXFRS producer

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.17.0, 2.18.5, 2.19.4, 2.20.2
    • Fix Version/s: 2.20.3, 2.21.1, 2.22.0
    • Component/s: camel-cxfrs
    • Labels:
      None
    • Environment:

      Java 8

    • Estimated Complexity:
      Unknown

      Description

      Given the sample MyProcessor, setting the DESTINATION_OVERRIDE_URL dynamically during the invoke:

      public void process(Exchange exchange) throws Exception {
          String env = (String)exchange.getIn().getHeader("Environnement");
          if (env.equalsIgnoreCase("DEV")) {
              exchange.getIn().setHeader(exchange.DESTINATION_OVERRIDE_URL,
                  "http://esbdev11.local:8080/server1/metaServlet");
          } else {
              exchange.getIn().setHeader(exchange.DESTINATION_OVERRIDE_URL,
                  "http://esblab11.local:8080/server2/metaServlet");
          }
      }
      

      Given the sample Route:

              from("cxfrs:bean:MyREST")
              .process(new HeaderProcessor())
              .setHeader("Environnement")
              .simple("${header.http_query[env][0]}")
              .process(new MyProcessor())
              .setHeader(org.apache.camel.Exchange.HTTP_METHOD, constant("GET"))
              .setHeader(org.apache.camel.Exchange.ACCEPT_CONTENT_TYPE, constant("*/*"))
              .setHeader(org.apache.camel.Exchange.HTTP_PATH, constant("/"))
              .to("cxfrs:bean:restClient?maxClientCacheSize=5");
      

      Send request to cxfrs:bean:MyREST with different http header "dev", then the cxfrs:bean:restClient always make call to the last setting Address.

      (Only it works as expected when setting maxClientCacheSize=0 on the cxfrs:bean:restClient)

      There is no this issue on Camel 2.16.x, but start problem from Camel 2.17.x and later versions. Investigations show that the CxfRsEndpoint becoming Singleton after CAMEL-9628, that explain why the last Address setting always applied.

        Attachments

          Activity

            People

            • Assignee:
              aldettinger Alex Dettinger
              Reporter:
              xldai Xilai Dai
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: