I currently have a JPA object for some tasks. Some processes write to this table, and the scheduled process works on these tasks and changes state when ready. I need to prioritize tasks and repeat them with decreasing frequency if they fail. My environment is GlassFish 3 + JPA through Hibernate + MySQL + XA transactions. In the medium term, the project will replace GlassFish with a Spring solution (using Jetty or so).
Somehow it worked out, but I'm not very happy with it: I get OptimisticLockExceptions, it seems that in some cases I didn’t receive the transaction, and the JPA timers on GlassFish are also messy if you need variable times.
I have the feeling that I am using the wrong tools here, and that I should use some kind of mature, stable design, and not something knocked down. Using JPA entities seems to be tough, but raw JDBC looks even worse. Of course, I want to avoid heavy dependencies in the library, but perhaps I am losing sight of the simple “canned” solution for my specific problem (which does not seem so unusual).
[change]
To clarify: I won’t change the use case (I don’t have the code anymore), I just want to get some general recommendations to “do it right” (TM) next time. To answer the question from ben75: the worker can be multithreaded, and I need small transactions, as this should be done all the time - maybe within a few months.
source share