Зарегистрируйте поток интеграции пружины и несколько подпотоков вручную - PullRequest
0 голосов
/ 10 июля 2019

После обновления до весенней загрузки 2.1.6.RELEASE запуск приложения завершается неудачно:

Полевая интеграцияFlow в org.springframework.cloud.stream.binder.AbstractMessageChannelBinder требует одного компонента, но найдено 2 :...

Я пытаюсь вручную зарегистрировать потоки, используя класс IntegrationFlowContext.

@Component
public class FlowCreator{

  @Autowired
  private IntegrationFlowContext flowContext;

  @Autowired
  private FlowExample flowExample;


  @PostConstruct
  public void registerIntegrationFlows() {

    flowContext.registration(flowExample.integrationFlow1())
    .id("integrationFlow1")
    .register();

    flowContext.registration(flowExample.integrationFlow2())
    .id("integrationFlow2")
    .register();
}

@Component
public class FlowExample {

  public IntegrationFlow integrationFlow1() {
    return IntegrationFlows.from("input")
        .<Object, Class<?>>route(Object::getClass, routeMessages()) //
        .get();
  }

  private Consumer<RouterSpec<Class<?>, MethodInvokingRouter>> routeMessages() {
    return m -> m //
        .subFlowMapping(Boolean.class, subFlow1()) 
        .subFlowMapping(Integer.class, subFlow2())
        .defaultOutputChannel("discardChannel");
  }

  private IntegrationFlow subFlow1() {
    return sf -> sf.channel("Channel1");
  }

  private IntegrationFlow subFlow2() {
    return sf -> sf.channel("Channel2");
  }

  public IntegrationFlow integrationFlow2() {
    return IntegrationFlows.from("input")
        .channel("channel3")
        .get();
  }
}

Теперь я получаю следующую ошибку:

Интеграция поляFlow в org.springframework.cloud.stream.binder.AbstractMessageChannelBinder требует одного компонента, но найдено 2:

  • integraFlow1.subFlow # 0: определено в нуле
  • integraFlow1.subFlow # 1: определено в нуле

1 Ответ

1 голос
/ 10 июля 2019

Это было исправлено в Spring Cloud Stream 2.1.1: https://github.com/spring-cloud/spring-cloud-stream/commit/794c75f5364b51d7ec89335b08bfaca0f6d4d139#diff-737803e2a91ac21a17baf06ff7b4cbac.

Рассмотрите возможность обновления до Fishtown SR3 или даже Germantown GA: https://spring.io/projects/spring-cloud-stream#learn

...