You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Giota Karadimitriou <Gi...@eurodyn.com> on 2006/03/10 09:48:07 UTC

session logout and repository shutdown in JCA

Hello,
 
I have been doing some investigation on how to perform session logout
and repository shutdown 
when using jackrabbit via JCA, as a resource adapter.
 
After searching the list I found out about the repository patch
http://issues.apache.org/jira/browse/JCR-245
which now (according to the jira issue) exists in version 1.0. Therefore
the repository shutdown is bound to happen when all sessions close.
This covers the second part of my question I guess.
 
However, using jackrabbit through jca means that transactions are now
handled by the container (application server). Session.logout
cannot be performed before the end of the transaction because data will
then be lost. Session.logout must be performed at the end of the
transaction
but in a J2EE environment you cannot tell for sure where the transaction
ends because a transactional method of a session bean might call/extend
some other transactional method etc. In this context it would be ideal
if the container could perform session.logout (I guess this is similar
to connection.close) at the end
of the transaction. 
 
Since sessions cannot be logged out explicitly before the end of the
transaction (because data will be lost) and are not closed by the
container at the end of the transaction, this leaves us with a lot of
active sessions.
 
Therefore besides the concurrent session problem, the repository cannot
be properly shut down since active sessions will exist.
 
I guess session are cleared after a certain timeout but can this timeout
be configured somewhere?
 
I posted sth like that to the list some days ago, so sorry for asking
again however I would just like some opinion to verify at least whether
this problem exists
and if it is in plan for jackrabbit to support sth like this in the
future.
 
Regards
Giota
 
  

Re: session logout and repository shutdown in JCA

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 3/10/06, Giota Karadimitriou <Gi...@eurodyn.com> wrote:
> After searching the list I found out about the repository patch
> http://issues.apache.org/jira/browse/JCR-245
> which now (according to the jira issue) exists in version 1.0. Therefore
> the repository shutdown is bound to happen when all sessions close.
> This covers the second part of my question I guess.

Note that JCR-245 was resolved by adding the TransientRepository
wrapper class for the main RepositoryImpl class. Automatic repository
shutdown only happens when you use the TransientRepository class.

As far as I know the jackrabbit-jca adapter uses RepositoryImpl
directly and takes care of repository shutdown based on lifecycle
information from the container, so there should be no problems due to
that.

BR,

Jukka Zitting

--
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development

RE: session logout and repository shutdown in JCA

Posted by Giota Karadimitriou <Gi...@eurodyn.com>.
Sorry for bringing up this thread again; I would like to thank Jukka for
giving me an answer on the second part of my question at that time and
would like to pose some additional question regarding the first part --
session logout when using JCA:
Because my problem is that I cannot explicitly logout the session (as it
has to happen at the end of the transaction or the data will be lost and
I do not know where the transaction ends), I tried to do the following
when login into the repository to get a session:

***
//add a custom connection listener to the managed connection
Session session=repository.login("userid",null);
JCASessionHandle sessionHandle=(JCASessionHandle)session;
JCAManagedConnection mc=sessionHandle.getManagedConnection();
mc.addConnectionEventListener(new CustomConnectionListener());

***
 

and to add a CustomConnectionListener

 

***

class CustomConnectionListener implements ConnectionEventListener {

            

public localTransactionCommitted(ConnectionEvent event) {
	System.out.println("transaction commited");
            JCASessionHandle sessionHandle=( JCASessionHandle )
event.getConnectionHandle();

            sessionHandle.logout();
}

public void connectionClosed(ConnectionEvent event){
    System.out.println("connection closed");
}
public void connectionErrorOccurred(ConnectionEvent event){
    System.out.println("connection error occured");
}
public void localTransactionRolledback(ConnectionEvent event) {
    System.out.println("transaction rolled back");
}
public void localTransactionStarted(ConnectionEvent event) {
    System.out.println("transaction started");
}

}

***

I also put print statements on the sendEvent method of the
JCAManagedConnection class.

However the 'local transaction commited' event is never fired.
Neither are any other events. 
My questions are therefore the following:

1. I have been trying to implement something in order to logout my
sessions automatically at the end of the transactions but I am not sure
whether I am on the right track here or I am trying to do something
unnecessary. Do I need to logout the sessions (in order to avoid
concurrent sessions problems)?. I have not received any feedback from
the list regarding this matter. Forgive me if I ask something obvious.
2. Why aren't the local transaction commited/rolledback events ever
fired? 
Do I need to do sth additional?


Regards
Giota


-----Original Message-----
From: Giota Karadimitriou [mailto:Giota.Karadimitriou@eurodyn.com] 
Sent: Friday, March 10, 2006 10:48 AM
To: jackrabbit-dev@incubator.apache.org
Subject: session logout and repository shutdown in JCA

Hello,
 
I have been doing some investigation on how to perform session logout
and repository shutdown 
when using jackrabbit via JCA, as a resource adapter.
 
After searching the list I found out about the repository patch
http://issues.apache.org/jira/browse/JCR-245
which now (according to the jira issue) exists in version 1.0. Therefore
the repository shutdown is bound to happen when all sessions close.
This covers the second part of my question I guess.
 
However, using jackrabbit through jca means that transactions are now
handled by the container (application server). Session.logout
cannot be performed before the end of the transaction because data will
then be lost. Session.logout must be performed at the end of the
transaction
but in a J2EE environment you cannot tell for sure where the transaction
ends because a transactional method of a session bean might call/extend
some other transactional method etc. In this context it would be ideal
if the container could perform session.logout (I guess this is similar
to connection.close) at the end
of the transaction. 
 
Since sessions cannot be logged out explicitly before the end of the
transaction (because data will be lost) and are not closed by the
container at the end of the transaction, this leaves us with a lot of
active sessions.
 
Therefore besides the concurrent session problem, the repository cannot
be properly shut down since active sessions will exist.
 
I guess session are cleared after a certain timeout but can this timeout
be configured somewhere?
 
I posted sth like that to the list some days ago, so sorry for asking
again however I would just like some opinion to verify at least whether
this problem exists
and if it is in plan for jackrabbit to support sth like this in the
future.
 
Regards
Giota