users@glassfish.java.net

java.nio.channels.ClosedByInterruptException on JMS message send from long-running SLSB

From: Steven Siebert <smsiebe_at_gmail.com>
Date: Thu, 14 Jul 2011 11:01:10 -0400

Hello,

I use JMS extensively throughout one of my EE projects and have noticed a
problem when using them with long-running EJB operations (ie scheduled
tasks). I'm hoping it simply a mis-configuration or improper implementation
I can easily remedy =)

Basically, I have a SLSB that uses resource injection to nab a
ConnectionFactory and Topic for my topic. Within these EJBs, I have long
running tasks that make remote SOAP calls, process results, use JPA to
store, blah blah...lots of time. When processing starts, everything runs
smooth. JMS messages make it to the topic, etc. Eventually, I get a
java.nio.channels.ClosedByInterruptException from jms, killing my
transaction (which is what I want as far as the transaction goes, but not
what I want as far as the untimely death part).

I believe what is happening (please correct me if I'm wrong) is that the
connection eventually times out due to it's long running (despite it's
continued, though sporadic, use throughout the task). If this is the case,
I suppose I could grab a connection using JNDI when I need it instead of
using resource injection as an EJB instance field. This way, I would let
the pool manage the connections and only serve me good connections when I
need it. The only down side is that I would be nabbing connections more
frequently...but I'm not really too worried about that since it's pooled.

Thoughts?

Thanks!

Steve