2 Replies Latest reply on Oct 5, 2013 2:21 AM by kozachuk-v

    The lifetime of a transaction in EJB

    kozachuk-v

      Out error when performing stateless bean: ... TransactionReaper::check timeout for TX .... so the program adds a row to the table and a lot of these lines. The process can take several hours.

       

      •      @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
      •     @TransactionTimeout(value = 1, unit = TimeUnit.HOURS)
      •     private void readF(File file){
      •     byte b [] = new byte[32];
      •     int row=0;
      •   while (inStm.available()>=16) {
      • ...read from file
      • ...insert to table

       

      annotations do not make effective until changed standalone.xml

       

           <subsystem xmlns="urn:jboss:domain:transactions:1.1">

                  <core-environment>

                      <process-id>

                          <uuid/>

                      </process-id>

                  </core-environment>

                  <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>

                  <coordinator-environment default-timeout="3600"/>

              </subsystem>

       

      how to properly install the lifetime of this particular transaction, not all?

        • 1. Re: The lifetime of a transaction in EJB
          sfcoy

          How is this particular operation started?

           

          Is it imperative that the whole operation be completed within a single transaction? In other words is a rollback required if there is a failure?

          • 2. Re: The lifetime of a transaction in EJB
            kozachuk-v

            Thank you. I'm not completely given issue

             

            @Resource(mappedName = "java:jboss/datasources/blackBoxDS", type = DataSource.class)

                private DataSource dataSource;

              private Connection dbConnection;

              private Statement statement;

            ...

              private void readF(File file){

                byte b [] = new byte[32];

                int row=0;

            try {

              dbConnection = dataSource.getConnection();

              statement = dbConnection.createStatement();

              dbConnection.setAutoCommit(false);

                 while (inStm.available()>=32){

                      row++;

                       inStm.read(b);

                      Event rEv= new Event(b)

                      sql = new String("INSERT INTO tabl_ (DDateTime,Fileld_) VALUE('"+rEv.getDate()+"',"+rEv.binToint(10,24)+")");

                       statement.executeUpdate(sql);

                      if (row % 2000 == 0)  dbConnection.commit();

                 }

                  if (row % 2000 != 0)  dbConnection.commit();

                 inStm.close();

              } catch (SQLException e) {

              // TODO Auto-generated catch block

              e.printStackTrace();

              }

             

            addition occurs on 2000 row. After 3 minutes of work I was getting error. After the decision was no change to the file standalone.xml. However, it applies to all transactions.  how to extend this particular transaction, this method is?

            @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

            @TransactionTimeout(value = 1, unit = TimeUnit.HOURS)

            Annotations as I understand it does not work here.