Соединения, открытые к SQL с помощью Apache ISIS не закрыты - PullRequest
0 голосов
/ 19 декабря 2018

Я использую Apache isis для API и использую SQL-сервер в качестве БД. Я заметил медлительность при выполнении запроса в БД.При расследовании я обнаружил, что соединения, которые были открыты Apache ISIS, не были закрыты и находились в спящем состоянии.Это привело к большому количеству открытых, но спящих соединений, что снизило производительность.Я прочитал документы apache isis и обнаружил, что пул соединений обрабатывается apache isis.Есть ли свойство, которое нам нужно добавить, чтобы соединения закрывались после закрытия сессии.Я застрял в этой проблеме, и любая помощь будет очень цениться.Заранее спасибо.Ура!

Редактировать: Persistor_datanucleus.properties

#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#  
#         http://www.apache.org/licenses/LICENSE-2.0
#         
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

#
# configuration file for the JDO/DataNucleus objectstore
#


#
# hook to perform additional initialization when JDO class metadata is loaded
# default implementation will attempt to run 'create schema' for the specified schema.
#
# this implementation is installed by default:
#isis.persistor.datanucleus.classMetadataLoadedListener=org.apache.isis.objectstore.jdo.datanucleus.CreateSchemaObjectFromClassMetadata


# whether to persist the event data as a "clob" or as a "zipped" byte[]
# default is "zipped"
#isis.persistor.datanucleus.PublishingService.serializedForm=zipped


#####################################################################
#
# DataNucleus' configuration
#
# The 'isis.persistor.datanucleus.impl' prefix is stripped off,
# remainder is passed through to DataNucleus
#
#####################################################################

isis.persistor.datanucleus.impl.datanucleus.schema.autoCreateAll=true
isis.persistor.datanucleus.impl.datanucleus.schema.validateTables=true
isis.persistor.datanucleus.impl.datanucleus.schema.validateConstraints=true


#
# Require explicit persistence (since entities are Comparable and using ObjectContracts#compareTo).
# see http://www.datanucleus.org/products/accessplatform_3_0/jdo/transaction_types.html
#
isis.persistor.datanucleus.impl.datanucleus.persistenceByReachabilityAtCommit=false


#
# How column names are identified 
# (http://www.datanucleus.org/products/datanucleus/jdo/orm/datastore_identifiers.html)
#
isis.persistor.datanucleus.impl.datanucleus.identifier.case=MixedCase

#
# L2 cache
# off except if explicitly marked as cacheable
# http://www.datanucleus.org/products/datanucleus/jdo/cache.html
#
isis.persistor.datanucleus.impl.datanucleus.cache.level2.type=none
isis.persistor.datanucleus.impl.datanucleus.cache.level2.mode=ENABLE_SELECTIVE



#
# uncomment to use JNDI rather than direct JDBC
#
#isis.persistor.datanucleus.impl.datanucleus.ConnectionFactoryName=java:comp/env/jdbc/quickstart

#
# uncomment to use JTA resource
#
#isis.persistor.datanucleus.impl.datanucleus.ConnectionFactory2Name=java:comp/env/jdbc/quickstart-nontx
#isis.persistor.datanucleus.impl.javax.jdo.option.TransactionType=JTA



#
#
# JDBC connection details
# ... are in persistor.properties
#
#

persistor.properties

#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#  
#         http://www.apache.org/licenses/LICENSE-2.0
#         
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.



#################################################################################
#
# Persistor
#
#################################################################################



# generally speaking this should not be enabled
isis.persistor.disableConcurrencyChecking=false

----Few lines that have been commented out----

isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL=jdbc:sqlserver://localhost:1433;database=myDB
    isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName=sa
    isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword=password

1 Ответ

0 голосов
/ 26 декабря 2018

Apache Isis использует пул соединений, предоставленный DataNucleus, который можно настроить, задав свойства конфигурации DN, см. http://www.datanucleus.org/products/accessplatform_4_1/persistence_properties.html

Чтобы указать их в persistor.properties, добавьте к ним префикс «isis.persistor.datanucleus»..impl «.- они передаются напрямую.

Также можно настроить Apache Isis для использования источника данных, предоставленного JNDI, см. http://isis.apache.org/guides/ugodn/ugodn.html#_ugodn_configuring_using-jndi-data-source

...