1 Reply Latest reply on Oct 9, 2009 2:58 AM by Vicky Kak

    Basic understanding of JCA-Workflow

    Hardy Massen Novice

      Hi!

      I've a JBoss AS 4.2.3 with a very basic SessionBean in it (code below), accessing a Jackrabbit-Repository, that is connected via a JCA-ConnectionFactory.

      Assuming the bean is deployed and the service-method deleteNode(...) is executed once. At which point is a connection to jackrabbit taken out of the pool?

      When the resource "java:jcr/local" is injected at bean-deployment?

      Or when repository.login(...) in the service-method is called?

      When is the connection released and returned to the pool? (When session-logout is called or when the transaction is committed or ... ?)

      Is it possible, that during a service-method more than one connection may be used?

      Any hints and references are really appreciated.

      Regards, LeoLo

      @Stateless
      @Remote(SimpleService.class)
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public class SimpleServiceBean implements SimpleService {
      
       // JackRabbit-Repository
       @Resource(mappedName = "java:jcr/local")
       private Repository repository;
      
       public void deleteNode (String path) {
      
       Session session = null;
       String pathLocal = null;
       Node oldNode = null;
      
       try {
       // JackRabbit access via JNDI
       session = this.repository.login(new SimpleCredentials("user", "pass".toCharArray()), "default");
      
       Node rootNode = session.getRootNode();
      
       oldNode = rootNode.getNode(pathLocal);
       oldNode.remove();
       session.save();
       }
       catch (RepositoryException re) {
       log.error(re.getMessage(), re);
       }
       finally {
       session.logout();
       }
       }
      


        • 1. Re: Basic understanding of JCA-Workflow
          Vicky Kak Master

           

          "LeoLo" wrote:

          Or when repository.login(...) in the service-method is called?

          The connection should be taken when login() is called, you can verify this by looking at the implementation.

          "LeoLo" wrote:

          When is the connection released and returned to the pool? (When session-logout is called or when the transaction is committed or ... ?)


          It should be when session.logou() is called, I would recommend to check the RA implementation from JackRabbit.

          "LeoLo" wrote:

          Is it possible, that during a service-method more than one connection may be used?

          Any hints and references are really appreciated.

          I can't make out from the methods calls that multiple connections are being used in the application flow.
          You can also look at the ManagedConnectionPool MBean from the jmx-console to see the evolution of the connections in the pool.