ConnectionPool:池为空-增加maxPoolSize或借款ConnectionTimeout [英] ConnectionPool: pool is empty - increase either maxPoolSize or borrowConnectionTimeout

查看:1817
本文介绍了ConnectionPool:池为空-增加maxPoolSize或借款ConnectionTimeout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的springboot应用程序遇到了这个问题,该应用程序连接到数据库和MQ,并使用Atomikos事务管理器.

I was facing this issue for my springboot application that connects to a DB and MQ, and uses Atomikos Transaction manager.

com.atomikos.jms.AtomikosJMSException|Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the AtomikosConnectionFactoryBean.
com.atomikos.datasource.pool.PoolExhaustedException: ConnectionPool: pool is empty - increase either maxPoolSize or borrowConnectionTimeout
    at com.atomikos.datasource.pool.ConnectionPool.waitForAtLeastOneAvailableConnection(ConnectionPool.java:326)
    at com.atomikos.datasource.pool.ConnectionPool.findOrWaitForAnAvailableConnection(ConnectionPool.java:144)
    at com.atomikos.datasource.pool.ConnectionPool.borrowConnection(ConnectionPool.java:132)
    at com.atomikos.datasource.pool.ConnectionPoolWithSynchronizedValidation.borrowConnection(ConnectionPoolWithSynchronizedValidation.java:23)
    at com.atomikos.jms.AtomikosConnectionFactoryBean.createConnection(AtomikosConnectionFactoryBean.java:601)
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:196)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.access$100(AbstractPollingMessageListenerContainer.java:77)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer$MessageListenerContainerResourceFactory.createConnection(AbstractPollingMessageListenerContainer.java:490)
    at org.springframework.jms.connection.ConnectionFactoryUtils.doGetTransactionalSession(ConnectionFactoryUtils.java:325)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:281)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:245)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1189)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1179)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1076)
    at java.lang.Thread.run(Thread.java:748)

我尝试打印maxPoolSize,发现它是1.此页面介于两者之间( https: //www.atomikos.com/Documentation/ConfiguringJms ),我找到了将MaxPoolSize增加到5的那行.我只是尝试将其设置为2并起作用.

I tried printing the maxPoolSize and found that it is 1. This page came across in between (https://www.atomikos.com/Documentation/ConfiguringJms) and I found the line where they increased the MaxPoolSize to 5. I just tried setting it to 2 and it worked.

AtomikosConnectionFactoryBean xaConnectionFactory = new AtomikosConnectionFactoryBean();
        xaConnectionFactory.setXaConnectionFactory(ibmMQXAConnectionFactory);
        xaConnectionFactory.setMaxPoolSize(2);

有人可以帮助我了解理想的池大小吗?它是做什么的?

Can someone help me to understand what should be the ideal poolsize. what it is for etc?

推荐答案

为了处理消息,Atomikos使用DB和JMS连接(在您的情况下). 这些连接来自可用连接池.要了解为什么需要连接池,请按照以下链接作为起点- Connection_pool

In order to process messages Atomikos uses DB and JMS connections (in your case). These connections are taken from the pools of available connections. To get the idea why connection pools are needed, please follow this link as a starting point - Connection_pool

简单地说-为了一次处理一条消息,Atomikos需要一个DB和一个JMS连接/会话.因此,如果您打算并行处理10条消息,则每个连接池的大小必须至少为10(对于DB为10,对于JMS连接池为10).

To put it simple - in order to process one message at a time Atomikos needs one DB and one JMS connection/session. So if you plan to process 10 messages in parallel, each connection pool size must be at least 10 (10 for DB and 10 for JMS connection pools respectively).

这篇关于ConnectionPool:池为空-增加maxPoolSize或借款ConnectionTimeout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆