ispsh 发表于 2016-10-28 08:23:26

Java DSL for Spring Integration 1.2 Milestone 2

@Autowired  
private EntityManagerFactory entityManagerFactory;
  
@Bean
  
public IntegrationFlow pollingAdapterFlow() {
  
    return IntegrationFlows
  
            .from(Jpa.inboundAdapter(this.entityManagerFactory)
  
                    .entityClass(StudentDomain.class)
  
                    .maxResults(1)
  
                    .expectSingleResult(true),
  
                e -> e.poller(p -> p.trigger(new OnlyOnceTrigger())))
  
            .channel(c -> c.queue("pollingResults"))
  
            .get();
  
}
  
@Bean
  
public IntegrationFlow updatingGatewayFlow() {
  
    return f -> f
  
            .handle(Jpa.updatingGateway(this.entityManagerFactory),
  
                    e -> e.transactional(true))
  
            .channel(c -> c.queue("persistResults"));
  
}
  
@Bean
  
public IntegrationFlow retrievingGatewayFlow() {
  
    return f -> f
  
            .handle(Jpa.retrievingGateway(this.entityManagerFactory)
  
                    .jpaQuery("from Student s where s.id = :id")
  
                    .expectSingleResult(true)
  
                    .parameterExpression("id", "payload"))
  
            .channel(c -> c.queue("retrieveResults"));
  
}
页: [1]
查看完整版本: Java DSL for Spring Integration 1.2 Milestone 2