I know I can limit the number of times the container tries to execute my MDB onMessage() method with rollbacks, I just can't find how to do it. Can anyone help?
"When you are up to your arm pits in alligators, it's hard to remember your there to drain the swamp."
In my case, I need to figure out why a Session Bean method called by my MDB won't persist my Entity
... but with onMessage() generating 20 rollbacks and retries to flood the log, I need to drain that swamp first.
Here's the rest of the detail:
I can tell from output my code writes to server.log that:
-- The MDB is being called,
-- A Session Bean is successfully injected as an MDB member, and.
-- The MDB reads the JMS message, prepares a reply, and sends it to a Queue successfully.
This is the last line from my MDB that successfully sends a reply:
if I allowed the MDB to return at that point, all works well and the java client that sent the first message receives a reply..
But I have code immediately following send() that invoke a method on the Session Bean -- process(). If I un-comment that line, the container tries to execute onMessage() 20 more times and each time writes the same errors and stack traces to flood server.log with endless errors.
When the line calling process() on the Session Bean is un-commented, I can tell from what my code writes to server.log that
-- everything through send() in onMessge still executes without error,
-- process() is in fact invoked in the Session Bean,
-- an Entity is successfully instantated in process() w/info passed to it from onMessage() taken from the original message,
-- and then process throws and Exception while trying to persist the entity
The container fills server.log with a set 1 of a long error list and stack trace.
Then onMessage() starts all over again.
-- it read the original message, Creates a reply message, executes send() again.
-- it invokes process() again which fails again.
The container fills server.log with a set 2 of a long error list and stack trace.
etc. 18 more times.
I have a try-catch block around the em.persist() line in process.
My MDB onMessage() has two try-catch blocks.
-- on encloses all code through and includoing send,
-- a 2nd one encloses this.bean.process();