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

Adding Http IntegrationFlows at runtime

    XMLWordPrintable

    Details

      Description

      I'm trying to develop an application that dynamically adds flows. I found a solution which using IntegrationFlowContext to dynamically add flows, but it seems not working with Http.inboundGateway or Http.inboundChannelAdapter.
      Here's what I did.

      @RestController
      public class TestController {
      
        @Autowired
        IntegrationFlowContext context;
      
        @Autowired
        ConnectionFactory mqConnectionFactory;
      
        @GetMapping("/register")
        public String registerFlows() {
          context.registration(IntegrationFlows.from(
            Tcp.inboundGateway(Tcp.netServer(10001)))
              .publishSubscribeChannel(subscribers -> subscribers.subscribe(f -> f.handle(Jms.outboundAdapter(mqConnectionFactory).destination("testQueue1"))))
              .get()).register();
          context.registration(IntegrationFlows.from(
            Http.inboundGateway("/hello/{country}")
              .requestMapping(r -> r.methods(HttpMethod.GET).params("msg"))
              .headerExpression("country", "#pathVariables.country")
              .payloadExpression("#requestParams.msg[0]"))
              .handle((payload, headers) -> "de".equals(headers.get("country")) ? "Hallo " + payload : "Hello " + payload)
              .get()).register();
          return "ok";
        }
      
      }
      
      

      IntegrationFlowContext.registration().register() is working with Tcp.inbound... or Jms.inbound... but not Http.

      Even if it's not right changing the service contract I think it is necessary to reconfigure it at runtime.

        Attachments

          Activity

            People

            Assignee:
            abilan Artem Bilan
            Reporter:
            ljhade24 Hyung Joo Lee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: