Activemq+zk HA集群
在一个台win7单机中,部署三个zk实例和三个mq实例。
往mq中发送10W+消息,启动监听器监听消息队列,在消费行为进行到2w+的时候,抛出异常,如下:
org.springframework.jms.listener.DefaultMessageListenerContainer handleListenerSetupFailure
警告: Setup of JMS message listener invoker failed for destination 'queue://textQueueMq' - trying to recover. Cause: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.
spring 消费者配置如下:
<!--生产者配置--> <bean id="consumerTargetConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="failover:(tcp://localhost:61616,tcp://localhost:61626,tcp://localhost:61636)?jms.prefetchPolicy.queuePrefetch=10"/> <property name="userName" value="admin"/> <property name="password" value="admin"/> <property name="useAsyncSend" value="true"/> <property name="maxThreadPoolSize" value="100"/> </bean> <!-- Spring用于管理真正的ConnectionFactory的ConnectionFactory --> <bean id="consumerConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <property name="targetConnectionFactory" ref="consumerTargetConnectionFactory"/> <property name="sessionCacheSize" value="100" /> </bean> <!--配置多个监听器--> <bean id="consumerMessageListener2" class="com.hispeed.listener.ConsumerMessageListener2"/> <!--配置监听容器--> <bean id="TestContainer2" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="connectionFactory" ref="consumerConnectionFactory" /> <property name="destination" ref="textQueueTTT"/> <property name="messageListener" ref="consumerMessageListener2"/> <!--同时启动多个消费者实例来提高消费的效率--> <!--<property name="concurrentConsumers" value="10"/>--> <property name="concurrency" value="5-10"/> <property name="sessionTransacted" value="true"/> </bean> |
mq配置如下:
<!-- http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software <!-- Allows us to use system properties as variables in this configuration file --> <!-- Allows accessing the server log --> <!-- <destinationPolicy> http://activemq.apache.org/slow-consumer-handling.html -->
http://activemq.apache.org/jmx.html <!-- http://activemq.apache.org/persistence.html <!-- <!-- http://activemq.apache.org/configuring-transports.html <transportConnectors> <!-- destroy the spring context on shutdown to stop jetty --> </broker> <!-- Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details </beans> |
请教mq大牛,看看是不是配置有问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
谢谢 tinshen的提醒,的确是mysql数据配置的问题,之前我用的是jdbc自带的数据源,我现在换成了dbcp数据源之后就没有上面的问题了,虽然不知道这两者有什么联系,但是问题是解决了。
mq不应该跟数据库配置有关系吧?
trying to recover. Cause: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.
数据库那里的代码检查一样。
为什么没办法创建数据库连接了。