我已將WireTap
配置添加到我的Spring集成Java DSL中。Spring集成Java DSL中的WireTap配置
我回顧討論What is the equivalent of logging-channel-adapter in java DSL現在我主要的Java配置文件看起來像
@Configuration
@Import(LoggerConfiguration.class)
@EnableIntegration
public class ProcessorConfiguration {
@Autowired
private WireTap wireTap;
@Bean
public QueueChannel inputChannel() {
return MessageChannels.queue(500)
.interceptor(wireTap)
.get();
}
@Bean
public PublishSubscribeChannel outputChannel() {
return MessageChannels.publishSubscribe()
.interceptor(wireTap)
.get();
}
...
}
而且LoggerConfiguration
是
@Configuration
public class LoggerConfiguration {
public static final LoggingHandler.Level INFO = LoggingHandler.Level.INFO;
@Bean
public WireTap wireTap() {
return new WireTap(loggerChannel());
}
@Bean
public IntegrationFlow loggerChain() {
return IntegrationFlows.from(loggerChannel())
.handle(loggerHandler())
.get();
}
@Bean
public MessageChannel loggerChannel() {
return MessageChannels.direct().get();
}
public MessageHandler loggerHandler() {
LoggingHandler loggingHandler = new LoggingHandler(INFO.name());
...
return loggingHandler;
}
}
的THES色調所有(!)的代碼只有達到我曾在這些簡單的行中的XML配置
<int:channel id="inputChannel">
<int:queue capacity="500"/>
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>
<int:publish-subscribe-channel id="outputChannel">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:publish-subscribe-channel>
<int:logging-channel-adapter id="logger" log-full-message="true" level="INFO"/>
怎麼可以我在Java DSL中配置wireTaps不那麼冗長和簡單?