7 Eylül 2023 Perşembe

SpringIntegration Content-Based Router

Örnek
Şöyle yaparız
@Configuration
public class ContentBasedRoutingConfig {

  @Bean
  public MessageChannel inputChannel() {
    return new DirectChannel();
  }

  @Bean
  public MessageChannel evenChannel() {
    return new DirectChannel();
  }

  @Bean
  public MessageChannel oddChannel() {
    return new DirectChannel();
  }

  @Bean
  Router(inputChannel = "inputChannel")
  public ExpressionEvaluatingRouter router() {
    SpelExpressionParser parser = new SpelExpressionParser();
    Expression expression = parser.parseExpression("payload % 2 == 0 ? 
      'evenChannel' : 'oddChannel'");
    return new ExpressionEvaluatingRouter(expression);
  }
}

Hiç yorum yok:

Yorum Gönder