These are chat archives for spring-cloud/spring-cloud

Mar 2019
Bruce Zhang
Mar 02 09:02

I'm asking a question on stackoverflow, help me with it.

In a microservice environment, spring-data-jpa paging queries cannot backfill the query data

Paging query on the client server requests resources server, server resources query results and return interface.I can't use it on the client server.I encapsulated it as an entity object but the problem was that the parameters of the conditional query could not be passed.

Resource Server

    public Page<RoleEntity> findAllPage(int page, int pageSize) {
        return roleDao.findAll(PageRequest.of(page-1, pageSize,"id"))));

Client server pagination

<nav aria-label="..." th:fragment="simplePage(jpaPageTool)">
    <ul class="pagination">
        <li class="page-item" th:classappend="${jpaPageTool.isFirstPage}?'disabled':''">
            <a class="page-link" th:href="@{${#request.getRequestURI()}(page=${})}" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
                <span class="sr-only">Previous</span>
        <div th:text="${#request.getQueryString()}"></div>

        <th:block th:if="${jpaPageTool.totalPages < 10}">
            <th:block th:each="pageNo : ${#numbers.sequence(1, jpaPageTool.totalPages)}">
            <li class="page-item " th:classappend="${ == pageNo}?'active':''">
                <a class="page-link" th:href="@{${#request.getRequestURI()}(page=${pageNo})}"  th:text="${pageNo}"></a>

        <li class="page-item" th:classappend="${!jpaPageTool.isLastPage}?'disabled':''">
            <a class="page-link" th:href="@{${#request.getRequestURI()}(page=${})}" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
                <span class="sr-only">Next</span>

How do you pass the parameters of a conditional query?

Spencer Gibb
Mar 02 15:12
@niyaode this is not the appropriate room
Tyler Van Gorder
Mar 02 21:32

@PatrickGotthard Sorry, a little late seeing your question. We managed to get things working with a combination of shutting down our tomcat connector using the following:

public class TomcatGracefullShutdownConnectorCustomizer implements TomcatConnectorCustomizer, ApplicationListener<ContextClosedEvent> {

    private volatile Connector connector;

    public void onApplicationEvent(ContextClosedEvent event) {
        if (this.connector == null) {
        Executor executor = this.connector.getProtocolHandler().getExecutor();
        if (executor instanceof ThreadPoolExecutor) {
            try {
                ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
                if (!threadPoolExecutor.awaitTermination(30, TimeUnit.SECONDS)) {
                        logger.warn("Tomcat thread pool did not shut down gracefully within 30 seconds. Proceeding with forceful shutdown");
            catch (InterruptedException ex) {

Remember that even if you unregister with Eureka, each ribbon client might has a cached copy of the server list. By pausing the connector, you will get a socket error and then all downstream client calls (from your gateway) should retry on the next available node.

Marcos Barbero
Mar 02 21:40
I can sound a little paranoid but the retry part should be present anyway, I mean, not just for de-registration but for the sake of a distributed system, the request can fail for a lot of reasons
Tyler Van Gorder
Mar 02 23:02
Right, you shouldn't have to build in a delay prior to shutting your service down. You shut it down, stop accepting new requests, wait for existing requests to finish, and exit. In the meantime, any future requests will failover to the next node.