Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-4460

Try to use preconfigured RestTemplate instance by default in HttpRequestExecutingMessageHandler

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 5.0.4
    • Fix Version/s: None
    • Labels:
      None

      Description

      Currently HttpRequestExecutingMessageHandler creates new instance of RestTemplate if no one specified explicitly.

      It may be more convenient to use preconfigured RestTemplate bean in current ApplicationContext. If there no RestTemplate beans then default to new instance.

      Example:

      @Configuration
      public class RestTemplateConfig {
      
          @Bean
          public RestTemplate restTemplate() {
              RestTemplate restTemplate = new RestTemplate();
              restTemplate.setRequestFactory(...);
              return restTemplate;
          }
      
      }
      
      @Configuration
      public class TestFlowConfig {
      
          @Bean
          public IntegrationFlow test() {
              return IntegrationFlows.from(Http.inboundGateway("/test"))
                  .handle(Http.outboundGateway("http://127.0.0.1/test")); // implicitly uses RestTemplate declared in RestTemplateConfig
                  .get();
          }
      
      }
      

        Attachments

          Activity

            People

            Assignee:
            abilan Artem Bilan
            Reporter:
            acc15 Vyacheslav
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: