Search code examples
spring-integrationspring-integration-dsl

JDBC Inbound Adapter retrieving only one record rather than all


I am using following jdbc inbound adapter that retrieves the message. There is another activator that monitors the channel and calls a method. However the issue is, the service activator is getting only one "Event" and not all. But, the query is supposed to "select *"

<int-jdbc:inbound-channel-adapter id="jdbcInboundAdapter"
                                 channel="queueChannel" data-source="datasource"
                                 auto-startup="true"
                                 query="SELECT * FROM Event" row-mapper="eventResultMapper"
                                 update-per-row="false">

    <int:poller fixed-rate="5000">
    </int:poller>
</int-jdbc:inbound-channel-adapter>

<int:service-activator input-channel="queueChannel" ref="eventActivator" method="doSomething">
</int:service-activator>

I have also tried to add max-rows="0" in the adapter, but that didn't help.


Solution

  • After further debugging, it turned out that the value of canProcessMessageList is false while creating ServiceActivatingHandler. Thus, service activator receives only one event rather than list.

    This is how my activator looked like:

    public void doSomething(Event event)
    {
      System.out.println("Processing event: " + event.getName());
    }
    

    Updated activator with following signature and it worked:

    public void doSomething(Collection<Event> events){
        System.out.println("Processing event: " + events.size());
        for (Event event: events){
            System.out.print("***** " + event.getName());
        }
    }