You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Max Peak <ma...@gmail.com> on 2017/07/10 20:47:40 UTC
Transaction timeouts
Greetings all,
I have a groovy script ( not a service) that collects (scrapes) data,
processes, and submits to db. If there are too many records, no error is
thrown but transaction timeout causes no records committed.
Is there a way to call forced commits occasionally during execution to clear
and reset the transaction queue?
Thanks a bunch
Max Peak
Re: Transaction timeouts
Posted by Michael Brohl <mi...@ecomify.de>.
Hi Max,
you can make use of TransactionUtil, see WebToolsService#entityExportAll
for an example.
The main pattern is
// start transaction
boolean beganTx = TransactionUtil.begin();
// iterate through generic values and store them, count numberWritten
...
// commit after 500 values
if (numberWritten % 500 == 0) {
TransactionUtil.commit(beganTx);
beganTx = TransactionUtil.begin();
}
// commit remaining values
TransactionUtil.commit(beganTx);
Hope that helps,
Regards,
Michael Brohl
ecomify GmbH
www.ecomify.de
Am 10.07.17 um 22:47 schrieb Max Peak:
> Greetings all,
>
>
>
> I have a groovy script ( not a service) that collects (scrapes) data,
> processes, and submits to db. If there are too many records, no error is
> thrown but transaction timeout causes no records committed.
>
> Is there a way to call forced commits occasionally during execution to clear
> and reset the transaction queue?
>
>
>
> Thanks a bunch
>
>
>
> Max Peak
>
>
>
>