Class PagingJdbcIterable<R>
java.lang.Object
org.axonframework.messaging.eventhandling.deadletter.jdbc.PagingJdbcIterable<R>
- Type Parameters:
R- The mapped result type.
- All Implemented Interfaces:
Iterable<R>
Enables iterating through a JDBC query using paging. Paging is taken care of automatically through the provided
PagingJdbcIterable.PagingStatementSupplier, fetching the next page when the items run out to iterate through.
Do not use this for paging when you care about concurrent deletes. If you loaded a page, delete an item from it, and load the next, you will miss an item during iteration.
The iterator() function can be called multiple times to loop through the items, restarting the query from
the start.
- Since:
- 4.8.0
- Author:
- Mitchell Herrijgers, Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassTheIteratorthat loops through the provided query's pages until it runs out of items.static interfaceDescribes a function that creates a newPreparedStatementthat pages results through the givenoffsetandmaxSize, ready to be executed. -
Constructor Summary
ConstructorsConstructorDescriptionPagingJdbcIterable(TransactionalExecutor<Connection> executor, PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier, int pageSize, Duration queryTimeout, JdbcUtils.SqlResultConverter<R> resultConverter, Function<SQLException, RuntimeException> errorHandler) Construct a newIterableof typeR, utilizing paging queries to retrieve the entries.PagingJdbcIterable(TransactionalExecutor<Connection> executor, PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier, int pageSize, JdbcUtils.SqlResultConverter<R> resultConverter, Function<SQLException, RuntimeException> errorHandler) Construct a newIterableof typeR, utilizing paging queries to retrieve the entries. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PagingJdbcIterable
public PagingJdbcIterable(TransactionalExecutor<Connection> executor, PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier, int pageSize, JdbcUtils.SqlResultConverter<R> resultConverter, Function<SQLException, RuntimeException> errorHandler) Construct a newIterableof typeR, utilizing paging queries to retrieve the entries.Uses a default query timeout of 30 seconds per page fetch.
- Parameters:
executor- TheTransactionalExecutorused to execute the paging query.pagingQuerySupplier- A factory function supply the pagingPreparedStatementto execute.pageSize- The size of the pages to retrieve. Used to calculate theoffsetandmaxSizeof the paging queryresultConverter- The converter of theResultSetinto entries of typeR.errorHandler- The error handler to deal with exceptions when executing a pagingPreparedStatement.
-
PagingJdbcIterable
public PagingJdbcIterable(TransactionalExecutor<Connection> executor, PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier, int pageSize, Duration queryTimeout, JdbcUtils.SqlResultConverter<R> resultConverter, Function<SQLException, RuntimeException> errorHandler) Construct a newIterableof typeR, utilizing paging queries to retrieve the entries.- Parameters:
executor- TheTransactionalExecutorused to execute the paging query.pagingQuerySupplier- A factory function supply the pagingPreparedStatementto execute.pageSize- The size of the pages to retrieve. Used to calculate theoffsetandmaxSizeof the paging queryqueryTimeout- The maximum time to wait for each page query to complete.resultConverter- The converter of theResultSetinto entries of typeR.errorHandler- The error handler to deal with exceptions when executing a pagingPreparedStatement.
-
-
Method Details