The current MDB implementation will wait for all "in flight" mdb requests to complete.
So if you don't have a mechanism to terminate prematurely, it will take as long as it takes.
There is no "kill immediately" option.
Thanks much for the clarification. My question would be--what would be a clean way to listen for a shutdown process? Is there a reliable place to trap when a shutdown begins? If so I can implement my own semaphore or trigger to stop the MDB from continuing.
It depends upon what your MDB is doing.
If it is stuck inside a cpu loop then you would need something inside that loop
to check the "stop processing now flag" at regular intervals.
If it invokes on other EJBs, you can add an interceptor to check it
and even mark any transaction as rollback only.
I don't want to bother you with many details, but this particular MDB is processing a stream. The processing can take from a few seconds to several minutes. The timing is not so critical, and I can add a flag in the loop to see if it should abort.
My question is, at the moment either a shutdown is requested, or a redeploy begins, what process can I trap in JBoss? Is there some completely reliable action/event/step that I can monitor for? I can manage the flag myself, and bailing out of the loop, I just don't know how to tell when JBoss is trying to shutdown or redeploy the app. Shutdown is more important, in this case.
The thread *should* receive an Interrupt. Well, I don't know if that's what the spec actually requires, but you'll get InterruptedIOException if you're doing a blocking read.
Nope, no exceptions thrown, which is what surprised me. I'd figured that at the worst, JBoss would just pull the rug out from underneath the sucker. Hence my post here.
I have the same problem, I need to implement a hook in the shutdown process to not wait for queues to process. Did you find a solution to your problem?
In the loop you should check for Thread.interrupted() anyway. Plus you can register for a JMX notification about the shutdown. See http://docs.jboss.com/jbossas/javadoc/4.0.4/system/org/jboss/system/server/Server.html