2017-06-04 2 views
1

Je tente de créer un flux qui reçoit un message de 2 sources (1 mqtt et une d'une interaction de service utilisateur) et génère un message vers un autre mqtt. En fait, j'essayer d'utiliser cette réponse: How to crate Spring Integration Flow from two MessageProducerSpec?Flux d'intégration de source avec deux sources

Et voici mon résultat:

@Bean 
public IntegrationFlow mqttInFlow() { 
    return IntegrationFlows.from(mqttInbound()) 
      .channel("mainMessageChannel") 
      .get(); 
} 

@Bean 
public IntegrationFlow mqttTestMessageFlow() { 
    return IntegrationFlows.from(messageService.testInbound()) 
      .channel("mainMessageChannel") 
      .get(); 
} 

@Bean 
public IntegrationFlow mainMessageFlow() { 
    return IntegrationFlows.from("mainMessageChannel") 
      .handle(eventServiceHandler()) 
      .split(operationSplitter()) 
      .handle(mqttOutbound()) 
      .get(); 
} 

Mais j'ai l'erreur suivante:

java.lang.IllegalStateException: 'outputChannel' or 'outputChannelName' is required 
    at org.springframework.util.Assert.state(Assert.java:70) 
    at org.springframework.integration.endpoint.MessageProducerSupport.afterSingletonsInstantiated(MessageProducerSupport.java:136) 

Répondre

1

Eh bien, vous devez l'utiliser dans ces MessageProducerSupport définitions, pas comme channel("mainMessageChannel"):

@Bean 
MessageProducerSupport mqttInbound() { 
    ... 
    adapter.setOutputChannelName("mainMessageChannel"); 
    ... 
} 

@Bean 
MessageProducerSupport testInbound() { 
    ... 
    adapter.setOutputChannelName("mainMessageChannel"); 
    ... 
} 

ou ... Juste ne pas @Bean annotation sur eux et Java DSL prendra soin de leur déclaration!