Я пытаюсь закодировать считыватель RSS-каналов с настроенным набором RSS-каналов. Я подумал, что хороший подход заключается в том, чтобы решить это путем кодирования прототипа-@Bean
и вызвать его с каждым RSS-каналом, найденным в конфигурации.spring-integration-dsl: Make Feed-Flow Work
Однако, я думаю, что я пропустил пункт здесь, когда приложение запускается, но ничего не происходит. Я имею в виду бобы созданы, как я бы ожидать, но нет никакого протоколирования происходит в этом handle()
-методе:
@Component
public class HomeServerRunner implements ApplicationRunner {
private static final Logger logger = LoggerFactory.getLogger(HomeServerRunner.class);
@Autowired
private Configuration configuration;
@Autowired
private FeedConfigurator feedConfigurator;
@Override
public void run(ApplicationArguments args) throws Exception {
List<IntegrationFlow> feedFlows = configuration.getRssFeeds()
.entrySet()
.stream()
.peek(entry -> System.out.println(entry.getKey()))
.map(entry -> feedConfigurator.feedFlow(entry.getKey(), entry.getValue()))
.collect(Collectors.toList());
// this one appears in the log-file and looks good
logger.info("Flows: " + feedFlows);
}
}
@Configuration
public class FeedConfigurator {
private static final Logger logger = LoggerFactory.getLogger(FeedConfigurator.class);
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public IntegrationFlow feedFlow(String name, FeedConfiguration configuration) {
return IntegrationFlows
.from(Feed
.inboundAdapter(configuration.getSource(), getElementName(name, "adapter"))
.feedFetcher(new HttpClientFeedFetcher()),
spec -> spec.poller(Pollers.fixedRate(configuration.getInterval())))
.channel(MessageChannels.direct(getElementName(name, "in")))
.enrichHeaders(spec -> spec.header("feedSource", configuration))
.channel(getElementName(name, "handle"))
//
// it would be nice if the following would show something:
//
.handle(m -> logger.debug("Payload: " + m.getPayload()))
.get();
}
private String getElementName(String name, String postfix) {
name = "feedChannel" + StringUtils.capitalize(name);
if (!StringUtils.isEmpty(postfix)) {
name += "." + postfix;
}
return name;
}
}
Что здесь не хватает? Кажется, мне нужно как-то «запустить» потоки.
Да, 1.2 работает нормально. Круто! Благодарю. – sjngm