我看到许多与 spring-integration-file 相关的示例。但我正在寻找一个示例应用程序,它使用 spring-integration-jpa 使用入站通道适配器从数据库中提取数据并从中创建一个 Java 对象。
任何帮助深表感谢。
我看到许多与 spring-integration-file 相关的示例。但我正在寻找一个示例应用程序,它使用 spring-integration-jpa 使用入站通道适配器从数据库中提取数据并从中创建一个 Java 对象。
任何帮助深表感谢。
在官方 Spring Integration Samples 存储库中有一个基本的 JPA 示例:https ://github.com/spring-projects/spring-integration-samples/tree/master/basic/jpa 。
入站通道适配器的简单 Java DSL 示例可能如下所示:
@Bean
public IntegrationFlow pollingAdapterFlow(EntityManagerFactory entityManagerFactory) {
return IntegrationFlows
.from(Jpa.inboundAdapter(entityManagerFactory)
.entityClass(StudentDomain.class)
.maxResults(1)
.expectSingleResult(true),
e -> e.poller(p -> p.trigger(new OnlyOnceTrigger())))
.channel(c -> c.queue("pollingResults"))
.get();
}