[jboss-user] [JCA/JBoss] - Re: Why is jboss closing my connection?
adrian@jboss.org
do-not-reply at jboss.com
Tue Jun 19 10:38:06 EDT 2007
The point I'm making is that you wouldn't do it that way (demarcate logon/logoff).
A user can logon and not do anything. You are wasting resources.
Instead you would allocate a connection for a unit of work (e.g. upload/download some files).
For each unit of work, you would "reauthenticate" based on the CRI or Subject.
That way you get maximum sharing of connections and you don't have
unused connections lying around when they are not being used.
The number of open connections is directly related to the number of active units of work,
not the number of SFSBs a lot of which could be idle.
This would be most efficient if the backend supports something like session suspension
as some telnet servers do.
Related to that is (if you are writing the back end yourself), you would be better using the
XAResource interface and storing the session against the XID on the backend server.
That way you can use "interleaving" where you start the session on one connection
suspend it (close() - returning the connection to the pool for somebody else to use)
and resume it on a different physical connection (or the same connection)
when you need it again.
e.g. psuedo code
| ConnectionFactory cf = ...
| Connection c = cf.getConnection(); // Allocate connection from pool - start the session - XAResource.start(xid, TMNOFLAGS);
| Object data;
| try
| {
| data = c.download();
| }
| finally
| {
| // Return the connection to the pool - suspend the session - XAResource.suspend(xid);
| c.close();
| }
|
| // Do some long running process, we don't need to have the connection for this
| // so let somebody else use it!
| Object result = calc(data);
|
| Connection c = cf.getConnection(); // Reget a connection - resume the session - XAResource.start(xid, TM_RESUME);
| try
| {
| c.upload(result);
| }
| finally
| {
| c.close();
| }
|
Finally, you also have greater ability to reap connections that are idle during low load periods.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055663#4055663
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055663
More information about the jboss-user
mailing list