Hi, let's say I have:
one Manager object
and
100-10,000 Connection objects
with the Connection objects receiving a message every ten seconds. Meaning in total receiving between 10 and 1,000 messages per second. On each message there is some data added to the database. All messages from the same connection are writing to the same entity (Device).
How can I improve the performance?
Currently I have a single EntityManager open on the Manager object level. However, I wonder if I should have an EntityManager per Connection (but this would be up to 10,000 open EntityManagers). Then I use transactions for each edit of the entity:
try { DefaultConnectionManager.this.entityManager.getTransaction().begin(); this.device = DefaultConnectionManager.this.entityManager.merge(this.device); this.device.getStates().add(state); this.device.setUpdate(this.hasUpdate(state)); this.device.setUpgrade(this.hasUpgrade(state)); DefaultConnectionManager.this.entityManager.getTransaction().commit(); } catch(OperationFailedException | InvalidEntityException e) { DefaultConnectionManager.this.entityManager.getTransaction().rollback(); }
I already get some errors from time to time (and here we are at around 100 Connection objects):
com.objectdb.o._PersistenceException: Attempt to begin a new transaction when a transaction is active [PMImpl] at com.objectdb.o._PersistenceException.a(_PersistenceException.java:47) at com.objectdb.o.JPE.d(JPE.java:147) at com.objectdb.o.ERR.h(ERR.java:56)
Thanks,
Martin