Код: Выделить всё
@Bean
IntegrationFlow eventFlow(
JdbcChannelMessageStore jdbcChannelMessageStore,
ExternalEventPublisher externalEventPublisher,
@Qualifier("transactionManager") TransactionManager transactionManager) {
return IntegrationFlow.from(eventInput())
.channel(eventOutput(jdbcChannelMessageStore))
.handle(
message -> {
ExternalEvent externalEvent = (ExternalEvent) message.getPayload();
externalEventPublisher.publishEvent(externalEvent);
},
e ->
e.poller(
Pollers.fixedDelay(Duration.ofSeconds(1))
.transactional(transactionManager)))
.get();
}
Я хотел бы сделать это одновременно, что я могу сделать, изменив Poller на это:
Код: Выделить всё
Pollers.fixedDelay(Duration.ofSeconds(1))
.maxMessagesPerPoll(20)
.taskExecutor(taskExecutor())
.transactional(transactionManager)
Код: Выделить всё
@Bean
TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(20);
executor.setQueueCapacity(100);
executor.setThreadNamePrefix("event-publisher-");
executor.initialize();
return executor;
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... tition-key
Мобильная версия