パブリッシュチャンネルのRabbitMQ接続仕様のリストから一連のコンシューマに移動する正しい方法は何ですか?あるSpringインテグレーションを使用した動的コンフィグレーション
、次のように私はウサギの設定を持っていると言う:私は@NestedConfigurationProperty List<RabbitConfiguration>
にこれらをマーシャリング
rabbits:
- hostname: blahblah
vhost: blahlbah
username: blahlbah
password: blahlbalh
exchange: blahblah
- hostname: blahblah1
vhost: blahlbah1
username: blahlbah1
password: blahlbalh1
exchange: blahblah1
...
。
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public AmqpTemplate amqpTemplate(RabbitConfiguration rabbitConfiguration) {
...
}
私は、基本的にIntegrationFlow
にそれをマッピングすることができます:
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public IntegrationFlow integrationFlow(AmqpTemplate amqpTemplate) {
return IntegrationFlows.from(inboundPubSubChannel()).handle(Amqp.outboundAdapter(amqpTemplate)).get();
}
は何、しかし、である私は、私にそれらList<RabbitConfiguration>
の1からAmqpTemplate
を取得しますので、のような@Bean
メソッドを書くことができList<RabbitConfiguration>
のためにこれを行う正しい方法で、結果としてList<IntegrationFlow>
がSpringによって処理されますか?
@Bean
public List<IntegrationFlow> integrationFlows(List<RabbitConfiguration> rabbitConfigurations) {
return rabbitConfigurations.stream()
.map(this::amqpTemplate)
.map(this::integrationFlow)
.collect(toList())
}