I have a JavaEE application that initiates long running transactions using a REST API (the requests return 202 Accepted).
I am using JMS to send progress messages to clients that have initiated these processes. However, no messages are sent until the long running process terminates. I believe this is because JMS is waiting for a commit and (by default) the container won't issue one until the process ends.
The majority of EJBs are @Stateless
including the long running process and the EJB sending the messages.
I "solved" this by adding @TransactionAttribute(REQUIRES_NEW)
on the method that sends the JMS message. I tried adding REQUIRES_NEW
to selected methods in the long running task code but that didn't seem to work.
I am concerned that the large number of commits will adversely affect performance. Is there a better way?