【发布时间】:2020-07-06 13:47:33
【问题描述】:
我创建了 MessagingGateway 和 2 个流。我得到了正确的清单。当我创建人时,程序会休眠。 为什么?我该如何解决这个问题?
MyService myService = context.getBean(MyService.class);
System.out.println("persons = " + myService.getPersons());
System.out.println("person = " + myService.save(new Person(0, "Alex")));
@MessagingGateway
public interface MyService {
@Gateway(requestChannel = "flow1.input")
@Payload("new java.util.Date()")
Collection<Person> getPersons();
@Gateway(requestChannel = "flow2.input")
Person save(Person person);
}
@Bean
public IntegrationFlow flow1(EntityManagerFactory entityManagerFactory) {
return f -> f
.handle(Jpa.retrievingGateway(entityManagerFactory)
.jpaQuery("from Person")
);
}
@Bean
public IntegrationFlow flow2(EntityManagerFactory entityManagerFactory) {
return f -> f
.handle(Jpa.outboundAdapter(entityManagerFactory)
.entityClass(Person.class)
.persistMode(PersistMode.PERSIST),
e -> e.transactional(true));
}
【问题讨论】:
标签: spring-integration spring-integration-dsl