I have a question about transaction performance and/or costs in following scenarios.
Environment: JBoss 7.1.1 / Oracle 11G / Java 6
Scenario A - 1 EJB:
I've created one EJB which saves a record to a database with CMP (Transaction REQUIRES_NEW):
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void saveTerminal(TerminalSaveRequest request) {
TerminalEntity terminalEntity = new TerminalEntity();
terminalEntity.setId(request.getId());
...
entityManager.persist(terminalEntity);
}
This EJB is called by an external EJB Client (without any JTA trx) and performes well (1000 inserts / sec). JBoss also documents the exact amount of transactions in the JPA measurement.
Scenario B - 2 EJBS:
I've changed the application and added a further EJB calling the EJB from scenario A, though here I would like to have a "shared" transaction opened by the new EJB. So I've changed the existing EJB as followed (Transaction REQUIRED):
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void saveTerminal(TerminalSaveRequest request) {
TerminalEntity terminalEntity = new TerminalEntity();
terminalEntity.setId(request.getId());
...
entityManager.persist(terminalEntity);
}
In the new EJB I start then the newly required transaction and calling the (local) EJB:
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void saveTerminal(TerminalSaveRequest request) {
terminal.saveTerminal(request);
}
Now, again everything works as expected (same amount of transactions etc), though the performance has dropped dramatically from 1000 to 200 inserts a second which bothers a lot as the transaction handling between these two EJBs seems to cost like 4 times the insert :(
Further informations:
Questions:
If more informations are needed I'll happily post more.
Thanks for any hints or thoughts about this topic.
Bernhard
Have you tried having both EJB's use @TransactionAttribute(TransactionAttributeType.REQUIRED)
and letting JBoss decide where to demarcate the transaction instead?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With