1
votes

I see many examples related to spring-integration-file. But I am looking for an example application where it uses spring-integration-jpa to pull data from database using Inbound Channel Adapter and create a Java object out of it.

Any help is much appreciated.

1
@Artem Bilan. Thank you for your response.Vicky

1 Answers

2
votes

There is a basic JPA sample in the official Spring Integration Samples repository: https://github.com/spring-projects/spring-integration-samples/tree/master/basic/jpa.

The simple Java DSL sample for Inbound Channel Adapter might look like this:

    @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();
    }