Skip to main content

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

4 replies [Last post]
smsiebe
Offline
Joined: 2009-02-19
Points: 0

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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
smsiebe
Offline
Joined: 2009-02-19
Points: 0

generate the connection as needed. Same problem, but it feels like it took
longer to error (although I didn't time things).

Same error (JMSException caused by
java.nio.channels.ClosedByInterruptException) but this time the connection
id's are different between each request (so I can see that it's requesting a
new connection on each call).

Snippet of my error:

javax.jms.JMSException: MQJMSRA_DS4001: JMSServiceException on send
message:sendMessage: Sending message failed. Connection ID:
7580738126500288000

Caused by: com.sun.messaging.jmq.jmsservice.JMSServiceException:
sendMessage: Sending message failed: Connection ID: 7580738126500288000

Caused by: com.sun.messaging.jmq.jmsserver.util.BrokerException: transaction
failed: java.nio.channels.ClosedChannelException

The JMS server is on the same JVM/GlassFish instance as the app is running.

S

On Thu, Jul 14, 2011 at 11:01 AM, Steven Siebert wrote:

> 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
>

Amy Kang Guest
Offline
Joined: 2010-11-13
Points: 0

The exception occurred while in sending message to broker (embedded).
Could you please provide the full stacktrace and the broker log which
is located in the under GlassFish instance subdirectory under imq/

On 11-07-14 09:05 AM, Steven Siebert wrote:
> Update: I changed to inline JNDI lookups to the ConnectionFactory and
> generate the connection as needed. Same problem, but it feels like it
> took longer to error (although I didn't time things).
>
> Same error (JMSException caused by
> java.nio.channels.ClosedByInterruptException) but this time the
> connection id's are different between each request (so I can see that
> it's requesting a new connection on each call).
>
> Snippet of my error:
>
> javax.jms.JMSException: MQJMSRA_DS4001: JMSServiceException on send
> message:sendMessage: Sending message failed. Connection ID:
> 7580738126500288000
>
> Caused by: com.sun.messaging.jmq.jmsservice.JMSServiceException:
> sendMessage: Sending message failed: Connection ID: 7580738126500288000
>
> Caused by: com.sun.messaging.jmq.jmsserver.util.BrokerException:
> transaction failed: java.nio.channels.ClosedChannelException
>
> The JMS server is on the same JVM/GlassFish instance as the app is
> running.
>
> S
>
>
>
>
> On Thu, Jul 14, 2011 at 11:01 AM, Steven Siebert > wrote:
>
> 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
>
>

smsiebe
Offline
Joined: 2009-02-19
Points: 0

Thanks for the reply! It will take me a little while to sanitize the log file, but I will provide it in the next post.

Thanks!

S

jassis
Offline
Joined: 2005-05-12
Points: 0

Hi, I know this is an old thread. I am getting same error on GlassFish 3.1.2.2 (build 5). The error is so random and I have been unable to reproduce it yet.