0

I am using Apache isis for API and using SQL server as DB.I noticed slowness in executing query in the DB. On investigating I found that the connections which were opened by Apache ISIS have not been closed and were on sleeping state. This led to a lot of open but sleeping connections thus reducing the performance. I read the apache isis docs and found that the connection pooling is being handled by apache isis. Is there a property that we need to add so that the connections are closed once the session is closed. I am stuck with this issue and any help would be very much appreciated. Thanks in advance. Cheers!

Edit: 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
  • You mean they're in a connection pool? and? define which connection pool you are using –  Dec 19 '18 at 18:00
  • I am not sure which connection pool ISIS framework uses internally – Sathiya Narayanan Dec 20 '18 at 05:01
  • @BillyFrost Can you please let me know which file you would want to look into because there are a lot of config files related to isis in my workspace – Sathiya Narayanan Dec 20 '18 at 10:06
  • @BillyFrost Added the files that seemed relevant to DB configuration. – Sathiya Narayanan Dec 21 '18 at 09:24
  • so it uses an internal DBCP2 connection pool as per DataNucleus docs, which releases connections if you close the PM and close the PMF –  Dec 21 '18 at 09:38
  • @BillyFrost Okay. What do you suggest I should do? – Sathiya Narayanan Dec 21 '18 at 09:42
  • only you know where is your PMF, or your PM and whether you have closed them. A connection pool with sleeping connections is not a cause for concern in most situations, and besides you can easily consult the DBCP / DataNucleus docs to configure it should you have an issue with the default –  Dec 21 '18 at 11:09
  • I am not explicitly using PM or PMF anywhere. I just mentioned the connection properties in the persistor.properties file. I need to go thru the DBCP docs. Thanks – Sathiya Narayanan Dec 21 '18 at 12:45

1 Answers1

1

Apache Isis uses the connection pool provided by DataNucleus, which can be configured by setting DN configuration properties, see http://www.datanucleus.org/products/accessplatform_4_1/persistence_properties.html

To specify these in persistor.properties, prefix them with "isis.persistor.datanucleus.impl." - these are passed through directly.

It is also possible to configure Apache Isis to use an JNDI-provided datasource, see http://isis.apache.org/guides/ugodn/ugodn.html#_ugodn_configuring_using-jndi-data-source

Dan Haywood
  • 2,215
  • 2
  • 17
  • 23