我有一个项目,其弹簧集成流程定义如下:
@Bean
public IntegrationFlow validationIntegrationFlow( ValidationService<String> validationService, ReleaseStrategy bundleReleaseStrategy ) {
return IntegrationFlows.from( FtpIntegrationFlowConfiguration.BANK_FTP_CHANNEL )
.split()
.enrichHeaders( headerEnricherSpec -> {
headerEnricherSpec.headerFunction( DESTINATION_CHANNEL_HEADER, message ->
validationService.validate( ( String ) message.getPayload() ) ?
BANK_FTP_VALID_CHANNEL : BANK_FTP_BAD_CHANNEL );
} )
.aggregate( aggregatorSpec -> aggregatorSpec
.correlationStrategy( message -> message.getHeaders().get( DESTINATION_CHANNEL_HEADER ) )
.releaseStrategy( bundleReleaseStrategy )
.expireGroupsUponCompletion( true )
.groupTimeout( 1000 )
.sendPartialResultOnExpiry( true ) )
.route( new HeaderValueRouter( DESTINATION_CHANNEL_HEADER ) )
.get();
}
这样做是验证每条消息并分配正确的目标标头然后将结果聚合在一起并将其发送到路由器以发送到正确的频道
我有一个检查流的服务,以便在启动时记录将发送的消息数量,在2个目标通道之后我有2个句柄告诉服务处理了一堆X大小,
下面有一个我得到的日志样本
2016-12-09 17:04:00.176 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | synchronize | Start sync for correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49] with value [7956]
2016-12-09 17:04:01.397 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1000] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [6956]
2016-12-09 17:04:01.752 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1000] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [5956]
2016-12-09 17:04:02.114 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1000] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [4956]
2016-12-09 17:04:02.410 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1000] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [3956]
2016-12-09 17:04:02.681 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1000] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [2956]
2016-12-09 17:04:02.991 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1000] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [1956]
2016-12-09 17:04:03.344 | [taskScheduler-2] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1000] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [956]
2016-12-09 17:04:05.538 | [taskScheduler-5] | INFO | org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler | expireGroup | Expiring MessageGroup with correlationKey[bad.channel]
2016-12-09 17:04:05.538 | [taskScheduler-5] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [1] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [955]
2016-12-09 17:04:05.590 | [taskScheduler-9] | DEBUG | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | Subtract [955] from correlationId [b5e69b73-aa99-4e9e-a7d2-59c015793a49]. Result is [0]
2016-12-09 17:04:06.635 | [taskScheduler-2] | WARN | service.sync.impl.SynchronizationServiceInMemory | subtractAndGet | counter for [b5e69b73-aa99-4e9e-a7d2-59c015793a49] not found, ignoring subtract of [955]
正如您在处理完所有消息后所看到的那样,我仍然在ExpireGroup日志之后记录一条警告,告诉我另一个包已经创建。
我尝试在聚合器之前放置日志,并且没有出现重复消息,任何人都可以帮我配置聚合器以便我不会重复吗?
ps:如果它可以提供任何帮助,那么我将如何实例化捆绑发布策略
new TimeoutCountSequenceSizeReleaseStrategy( 100, 1000L );