Reputation: 63
int-jdbc:inbound-channel-adapter needs int:poller to work, both have max-rows and max-messages-per-poll respectively.
a) Why inbound-channel-adapter needs poller. why it can't have default poller in-built?
b) What if max-rows and max-messages-per-poll has different values?
c) Why poller(o.s.i.e.SourcePollingChannelAdapter) keeps polling(or try to) when a set of messages are polled and being processed?
<int-jdbc:inbound-channel-adapter
query="${poller.deliveryLocator.dnd.get}"
max-rows="${poller.deliveryLocator.dnd.maxRow}"
row-mapper="deliveryLocatorPollerRowMapper" data-source="dataSource"
channel="deliveryLocatorChannel">
<int:poller fixed-rate="500" time-unit="MILLISECONDS" max-messages-per-poll="${poller.deliveryLocator.dnd.maxRow}">
<int:transactional />
</int:poller>
</int-jdbc:inbound-channel-adapter>
For question "c", I did set debug level logger for org.springframework and blocked the program by having a break point at row-mapper.
I noticed poller keeps polling the DB(these debug statements were repeating) however, it was not picking any records because inbound-channel-adapter was blocked.
2019-06-10 15:16:29 [task-scheduler-1] DEBUG
o.s.orm.jpa.JpaTransactionManager - Creating new transaction with name
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.orm.jpa.JpaTransactionManager - Opened new EntityManager [SessionImpl(1259297282<open>)] for JPA transaction
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.orm.jpa.JpaTransactionManager - Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@621f9b19]
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.i.e.SourcePollingChannelAdapter - Received no Message during the poll, returning 'false'
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.orm.jpa.JpaTransactionManager - Initiating transaction commit
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.orm.jpa.JpaTransactionManager - Committing JPA transaction on EntityManager [SessionImpl(1259297282<open>)]
2019-06-10 15:16:29 [task-scheduler-1] DEBUG o.s.orm.jpa.JpaTransactionManager - Closing JPA EntityManager [SessionImpl(1259297282<open>)] after transaction
Upvotes: 0
Views: 540
Reputation: 174554
a) You can define a default poller (see the documentation).
b) Max rows is a way to limit the number of rows fetched on each poll (the message payload is a collection of rows or mapped objects); max-messages-per-poll is how many times to poll the database between poll intervals.
c) It will only do that if you hand off the work to another thread. If you process the results on the poller thread, the next poll won't happen until the current one finishes.
I don't know what you mean by "...was blocked".
Upvotes: 0