1

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. Commented Mar 14, 2019 at 15:06

1 Answer 1

3

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 IntegrationFlow
                .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();
    }
Sign up to request clarification or add additional context in comments.

5 Comments

Why are (almost) all the examples XML-based in that repository? It's so painfull.
Because they have been made those old days when only an XML configuration existed. Right now we just don't have enough resources to maintain Java DSL samples as well.
For java configurations you can see here docs.spring.io/spring-integration/reference/html/…
FTR IntegrationFlows is now deprecated so this is no longer the correct answer.
Have just fixed my answer. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.