java - 使用ActiveMQ-pool建立的连接总是无任何征兆的自动关闭。
阿神
阿神 2017-04-17 16:47:50
0
1
631

在消费者端使用PooledConnectionFactory建立与MQ服务器的连接,启动的时候初始化10个消费者。相关代码如下:

protected JMSConnectionUtill(String MQ_LOCATION,String userName,String password) { this.MQ_LOCATION=MQ_LOCATION; this.userName=userName; this.password=password; // ConnectionFactory :连接工厂,JMS 用它创建连接 ActiveMQConnectionFactory connectionFactory = null; if(StrKit.notBlank(userName) && StrKit.notBlank(password)){ connectionFactory= new ActiveMQConnectionFactory(userName, password, MQ_LOCATION); } else{ connectionFactory= new ActiveMQConnectionFactory(MQ_LOCATION); } pooledConnectionFactory = new PooledConnectionFactory(); pooledConnectionFactory.setConnectionFactory(connectionFactory); // 设置最大连接数 pooledConnectionFactory.setMaxConnections(100); // 设置最小 pooledConnectionFactory.setMaximumActiveSessionPerConnection(500); pooledConnectionFactory.setIdleTimeout(Integer.MAX_VALUE); }

但是连接总是隔一段时间就完全无征兆的自己关闭了。为此查了很久,都没有找到原因。哪位大神指导如何解决?

阿神
阿神

闭关修行中......

reply all (1)
刘奇

Comment out this sentence pooledConnectionFactory.setIdleTimeout(Integer.MAX_VALUE);

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!