Hi Ingo, You can use dispatcher.runSync with requireNewTransaction true eg. try { Map<String, Object> result = dispatcher.runSync(serviceName, serviceInCtx , transactionTimeout, true);
if (!ServiceUtil.isSuccess(result)) { Debug.logError(ServiceUtil.getErrorMessage(result), MODULE); } } catch (GenericServiceException gee) { Debug.logError(gee, MODULE); } In this way you don't need to explicitly commit and begin the transaction. Thanks & Regards -- Deepak Dixit ofbiz.apache.org On Wed, Sep 20, 2023 at 9:45 PM Ingo Wolfmayr <ingo.wolfm...@wolfix.at> wrote: > Solved it myself. > > I set the service to manual transaction (use-transaction="N") and set > TransactionUtil.begin() at the beginning and TransactionUtil.commit() at > the end of every loop. > > Cheers, > Ingo > > -----Ursprüngliche Nachricht----- > Von: Ingo Wolfmayr <ingo.wolfm...@wolfix.at> > Gesendet: Mittwoch, 20. September 2023 08:30 > An: user@ofbiz.apache.org > Betreff: Transaction > > Hi everybody, > > I have a question regarding transaction: > > I have a service that parses a big file and creates products from it. > > 100.000 products > > If I do a TransactionUtil.commit() after each product, do I have to add a > TransactionUtil.begin() for the next loop? > > - Service starts and creates a transaction > - Product 1 --> commit > - Product 2 --> commit > > or should I disable the service transaction via use-transaction="N" > > - Service starts - no transaction > - begin --> Product 1 --> commit > - begin --> Product 2 --> commit > > The goal is to reduce memory consumption. > > Best regards, > Ingo >