Bonjour,
Je suis en train de mettre en place MongoDB dans une application et une donnée m'ennuie :
Il semblerait que les connections ne soient jamais relâchées.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 Mon Sep 9 11:34:07.336 [initandlisten] connection accepted from 127.0.0.1:47409 #11 (1 connection now open) Mon Sep 9 11:34:13.451 [initandlisten] connection accepted from 127.0.0.1:47414 #13 (2 connections now open) Mon Sep 9 11:34:15.377 [initandlisten] connection accepted from 127.0.0.1:47415 #14 (3 connections now open) Mon Sep 9 11:35:26.508 [initandlisten] connection accepted from 127.0.0.1:47420 #16 (4 connections now open) Mon Sep 9 11:35:31.400 [initandlisten] connection accepted from 127.0.0.1:47421 #17 (5 connections now open) Mon Sep 9 11:36:37.089 [initandlisten] connection accepted from 127.0.0.1:47426 #18 (6 connections now open) Mon Sep 9 11:36:38.419 [initandlisten] connection accepted from 127.0.0.1:47427 #19 (7 connections now open) Mon Sep 9 11:38:02.152 [initandlisten] connection accepted from 127.0.0.1:47432 #20 (8 connections now open) Mon Sep 9 11:38:09.243 [initandlisten] connection accepted from 127.0.0.1:47433 #21 (9 connections now open) Mon Sep 9 11:39:15.769 [initandlisten] connection accepted from 127.0.0.1:47438 #22 (10 connections now open) Mon Sep 9 11:39:18.539 [initandlisten] connection accepted from 127.0.0.1:47439 #23 (11 connections now open) Mon Sep 9 11:40:23.533 [initandlisten] connection accepted from 127.0.0.1:47449 #24 (12 connections now open) Mon Sep 9 11:41:31.842 [initandlisten] connection accepted from 127.0.0.1:47454 #25 (13 connections now open) Mon Sep 9 11:42:39.244 [initandlisten] connection accepted from 127.0.0.1:47459 #26 (14 connections now open) Mon Sep 9 11:43:47.683 [initandlisten] connection accepted from 127.0.0.1:47464 #27 (15 connections now open) Mon Sep 9 11:44:56.991 [initandlisten] connection accepted from 127.0.0.1:47469 #28 (16 connections now open) Mon Sep 9 11:46:01.443 [initandlisten] connection accepted from 127.0.0.1:47481 #29 (17 connections now open)
Est-il possible de mettre un timeout sur les connexions ?
Voici ma configuration actuelle (SpringConfig.xml) :
Appelé par :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation= "http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <mongo:mongo host="mongodb.monserveur.local" port="27017" > <mongo:options connections-per-host="10" threads-allowed-to-block-for-connection-multiplier="4" connect-timeout="1000" max-wait-time="1500" auto-connect-retry="true" socket-keep-alive="true" socket-timeout="60000" slave-ok="true" write-number="1" write-timeout="0" write-fsync="false" /> </mongo:mongo> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongo" /> <constructor-arg name="databaseName" value="mabase" /> </bean> </beans>
J'ai trouvé sur cette page (http://docs.mongodb.org/manual/refer...ection-string/ la propriété "maxIdleTimeMS" mais je ne sais pas comment la mettre en place.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 ApplicationContext context = new GenericXmlApplicationContext("SpringConfig.xml"); MongoOperations mongoOperation = (MongoOperations) m_context.getBean("mongoTemplate");
Merci d'avance.
NB : je travaille sous Ubuntu.
Partager