Thanks Santhosh, I know I *can* reuse sessions, but my question is that is there a 'significant reason' to do so.
In my code its a lot easier to create a connection for each operation, but if there is a significant advantage to reusing the same connection for multiple requests, such as performance or transactional issues, then I might need to code for that. But that adds complexity, in particular the user would have to script a "login" type command, and also particularly difficult would be enforcement of closing the session object. From: [email protected] [mailto:[email protected]] On Behalf Of Santhosh Raj Sent: Wednesday, May 06, 2009 5:40 AM To: General Mark Logic Developer Discussion Subject: Re: [MarkLogic Dev General] Connection Caching Hi Lee, Yes you can create only one session object and you can do any number of xcc operations (say run newAdhocQuery or what ever you need). At the end finally you can close the session object. Eg: session = contentSource.newSession(); File file = new File("C:\\MarkLogic\\abc.xml"); InputStream is = new FileInputStream(file); ContentCreateOptions createOptions = new ContentCreateOptions(); createOptions.setFormatBinary(); Content content = ContentFactory.newContent("transaction5.xml", is, createOptions); session.insertContent(content); System.out.println(" Document Inserted:" ); Request request = session.newAdhocQuery("xdmp:document-insert(\"111.xml\" ,\"<a1> abc 111</a1>\")"); ResultSequence rs = session.submitRequest(request); In this example same session object is used to do 2 operations . You can also do the same. Regards, Santhosh Rajasekaran "Lee, David" <[email protected]> Sent by: [email protected] 05/06/2009 12:34 AM Please respond to General Mark Logic Developer Discussion <[email protected]> To "General Mark Logic Developer Discussion" <[email protected]> cc Subject [MarkLogic Dev General] Connection Caching I read that the ML xcc library handles "connection pooling" .. .but does it handle "connection caching" ? What I mean is this. Suppose I were to do 10 XCC operations (say run newAdhocQuery). Is there a significant advantage to reusing a session ? Vs. creating a new session for each one. The context of the question ... I'm working on the ML connector to xmlsh (www.xmlsh.org) and I'm wondering if there is a significant advantage to complicating the API. Right now every ML operation creates a new session (from a connection string like "xcc://user:p...@host:port/DB") then runs the operation. Would there be a significant advantage to instead having a kind of "login" method and then reusing the session instead of creating a new one. Any opinions welcome ! -David Lee ---------------------------------------- David A. Lee Senior Principal Software Engineer Epocrates, Inc. [email protected] 812-482-5224 _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general <http://xqzone.com/mailman/listinfo/general> ForwardSourceID:NT0000AE2E =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
