Re: close Connection of EOEditingContext
Re: close Connection of EOEditingContext
- Subject: Re: close Connection of EOEditingContext
- From: Chuck Hill <email@hidden>
- Date: Thu, 4 Nov 2004 09:31:15 -0800
On Nov 4, 2004, at 9:03 AM, Damien Lust wrote:
I will propose to my client to keep a session active ( webobjects
philosophy) but create new one in thread and kill at the end of thread
,
I don't know what you mean by than.
and kill the defaultEditingContext at session TimeOut / Logout,
The frameworks dispose of it for you when a session terminates.
instead of create/kill session at each transation (anti-webobjects
philosophy)
Perhaps what you want is DirectActions?
public WOActionResults spooAction() {
WOActionResults result = null;
EOEditingContext ec = new EOEditingContext();
ec.lock();
try {
WOComponent resultPage = pageWithName("BigSpooPage");
// Setup your page here
result = resultPage.generateResponse();
}
finally {
ec.unlock();
ec.dispose();
}
// Error case: handle result == null here
return result;
}
In my case there is another particularity:
Each user must have a connection with a workSessionToken ( all access
on the DB test if the user has a workSession Active)
For each user , i create a defaultEdittingContext like that:
eoEditingContext.setSharedEditingContext(null);
eoEditingContext.setUndoManager(null);
//Procedure that active the workSession
String storedFunction = "{ call
PK_ACCESS_CONTROL.setCurrentWorkSession('"+workSessionToken+"')}";
// Param returned from another procedure that create a
workSessionToken from a login and password
EOUtilities.rawRowsForSQL(eoEditingContext,"WDLParameter",storedFunctio
n,null);
session.setDefaultEditingContext(eoEditingContext);
Looks like you are using an unlocked EC to me!
For each access to list and object i use this defaultEditingContext
When a execute a long request ( My application is a Query Tool, user
define a complex query on fields and execute it),
To do that I create a thread (No a WDLLongResponsePage), with a new
EOEditingContext create from a new EOObjectStoreCoordinator()
eoCoord = new EOObjectStoreCoordinator();
editingContext = new EOEditingContext(eoCoord);
editingContext.setSharedEditingContext(null);
editingContext.setUndoManager(null);
// Set workSessionToken
String storedFunction = "{ call
PK_ACCESS_CONTROL.setCurrentWorkSession('"+session.workSessionToken()+"
')}";
EOUtilities.rawRowsForSQL(editingContext,"DLQTModel",storedFunction,nul
l);
At the end of my thread
try {
editingContext.dispose();
eoCoord.dispose();
editingContext=null;
eoCoord=null;?
}catch(Exception e) {
e.printStackTrace();
}
In addition, in the methode terminate of the Session()
I have :
defaultEditingContext().parentObjectStore().dispose();
defaultEditingContext().dispose();
But when 2 users are connected and after a session timeout , it kills
oracle session of my first user but not that of the second, i have yet
oracle connection open ....
Do i something wrong?
I don't know, I got lost.
Chuck
On 03 Nov 2004, at 18:42, Lenny Marks wrote:
On Nov 3, 2004, at 12:04 PM, Damien Lust wrote:
If 200 users make the same request at the same time ( a display of a
big list) , one connection for all request will be very slow.
I can say that it would most definitely perform a lot better than
acquiring multiple database connections per request. It is true that
only one editing context can have a lock on the EOF stack at a time,
but in practice, as long as the your database queries are performing
reasonably, the EOF stack will not be a bottleneck. All editing
contexts sharing the same EOObjectStoreCoordinator(stack) share a row
cache. Depending on the nature of your data and your application, it
is likely that the shared row cache will be hit instead of the
database, greatly reducing the time any one editing context will hold
a lock on the stack.
This topic gets deep and has been discussed many times before on the
list. Depending on how many users are sharing one stack, it will
eventually become necessary to scale up either by adding application
instances or stacks within one multithreaded app. Once there are
multiple stacks, there are staleness issues caused by the row caches
in different stacks. Anyway, if you are just starting out, I would
definitely recommend starting simple and worry about the rest as
needed. There are also thread safety issues(locking/unlocking) to
worry about when using editing contexts other then the
session.defaultEditingContext. Best to start using vanilla WO.
I would also recommend setting EOAdaptorDebugEnabled=true your .woa
Properties file. If you have WORepetitions where each row traces
multiple relationships on EO's, you may see that there are far more
db round trips then need be. This can be greatly improved using
prefetching or batch faulting as necessary.
http://wocode.com/cgi-bin/WebObjects/WOCode.woa/wa/ShareCodeItem?
itemId=337
-lenny
On 03 Nov 2004, at 17:50, Lenny Marks wrote:
Is there a very good reason you are using a separate EOF
stack(EOObjectStoreCoordinator) for each editing context? Why not
use session.defaultEditingContext()? There would be only one
connection shared by all users in that case.
-lenny
On Nov 3, 2004, at 11:44 AM, Damien Lust wrote:
On 03 Nov 2004, at 17:24, Ken Anderson wrote:
Damien,
If you're saying you need to completely disconnect from the
database, getting rid of the editing context is not going to do
that. In my opinion, it would be a lot easier to convince the
client that you need to maintain a connection than it will be to
convince EOF to disconnect from the database then reconnect.
Can you share the reason they don't want a persistent connection
to the database?
That's his argument:
If 200 users display a list, only to read content of the list,
200 open connections are present and no used.
Ken
On Nov 3, 2004, at 11:16 AM, Damien Lust wrote:
I use Oracle as DataBase for the development of WebObject
Application.
When i display a page that display a list, when the list has
been displayed , no more connection (session oracle) must exist.
( It's in the specifications of my client)
I use the SQL script to verify that:
SELECT s.sid,
s.serial#,
s.osuser,
s.program
FROM v$session s;
So my solution:
I have a method that returns a EOEditingContext for all others
methods/accessors of the page
public EOEditingContext editingContext() {
if (editingContext==null) {
editingContext = new EOEditingContext(new
EOObjectStoreCoordinator());
editingContext.setSharedEditingContext(null);
editingContext.setUndoManager(null);
}
return editingContext;
}
EOEditingContext editingContext;
At the end of the appendToResponse, i try to dispose this
eoeditingContext:
if (editingContext!=null) {
editingContext.dispose();
if (editingContext.parentObjectStore()!=null)
editingContext.parentObjectStore().dispose();
editingContext=null;
}
But i have some problems:
- The number of oracle sessions is growing after each refresh
of the page
- My page use batch to navigate throw the list , i use
displayGroup , my application crashs because the editingContext
of the dislayGroup is reset and set to null ( It works if i use
a defaultEditingContext from the session)
Any ideas?
Thanks a lot.
_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden