0 Replies Latest reply on Jul 12, 2013 1:48 AM by MarcGriebenow

    How to use transaction in jsp in CQ5.5

    MarcGriebenow Level 1

      Hello,

       

      i'm playing around with transactions Jackrabbit should be capable of

       

      I didn't find any resource to that specific topic.

       

      Here's my code so far, but it isn't working properly...

       

      final SlingRepository repository = sling.getService(SlingRepository.class);
      Session session = repository.loginAdministrative(null);

      UserTransaction utx = sling.getService(UserTransaction.class);
      utx.begin();
      out.println(utx.getStatus());
      Node node = session.getNode("/path/to/a/content");
      node.setProperty("a","property");
      session.save();
      out.println(utx.getStatus());
      utx.rollback();
      session.logout();

       

      Expected result: The Property "a" is not appended to the node because Transaction was rolled back

       

      Achieved result so far: The property is saved to the node.

       

      What am i doing wrong?

      What is the preferred way to use transaction?

       

      Background: we are doing some asset operations in user profile node that take some time. It seems that the reverse replication launcher starts in between the process and breaks the replication process every now and then

       

       

      Thanks for advice

       

      Marc