I figured it out. I create the database in the singleton, adding all the necessary XML documents. When the thread needs to perform a query I just create a new instance of the client session and open the database. The performance is excellent!!
-----Original Message----- From: Bondeson, Carl Sent: Tuesday, September 23, 2014 12:58 PM To: Bondeson, Carl; Christian Grün Cc: basex-talk@mailman.uni-konstanz.de Subject: RE: [basex-talk] Multi threaded application
Can I create a BaseX database in the singleton, add the necessary documents to it, and then reference this database in any thread wishing to create connect client session to it? I don't see this discussed anywhere.
Thanks
-----Original Message----- From: basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de] On Behalf Of Bondeson, Carl Sent: Thursday, September 18, 2014 9:27 AM To: Christian Grün Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] Multi threaded application
I forgot that since the server was started and the database constructed in the singleton, any new instances will still have access to it. I was using the client session as a permanent object rather than recreating these for each class instance.
-----Original Message----- From: Christian Grün [mailto:christian.gruen@gmail.com] Sent: Thursday, September 18, 2014 7:25 AM To: Bondeson, Carl Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] Multi threaded application
Hi Carl,
Exception: Unknown Query ID:
The exception indicates that you are launching concurrent queries with a single client session. I surely know too less about your concrete implementation, but are the some specific reasons for avoiding the creation of multiple ClientSession objects?
Best, Christian
I have using BaseX in a canonical manner to handle the many translations used in ELR systems. I won't get into specifics but it has been working well. I started looking into the use of a singleton database object in place of the many ClientSession objects created in the constructor of the associated classes. In a single thread the performance varied between a 2x and 5x decrease. That would be expected since the amount of i/o required to load the XML would be replaced by simply executing queries against the database. The application that is utilizing BaseX is multithreaded. Once I deployed the application in JBoss I continue to receive exceptions:
These class methods are "synchronized" and are being invoked via Xalan callouts from XSLT.
I am currently using version 7.9 from the Maven repository.
Is BaseX thread safe in this manner?
Carl R Bondeson Systems Developer Department of Public Health Data Processing 410 Capitol Ave Hartford, CT 06134 Phone: 860-509-7434 carl.bondeson@ct.gov