Patches item #758059, was opened at 2003-06-20 18:05
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376687&aid=758059&group_id=22866
Category: JBossMQ
Group: v2.4 (stable)
Status: Open
Resolution: None
Priority: 5
Submitted By: Dennis M. Kremer (kremerd)
Assigned to: Nobody/Anonymous (nobody)
Summary: SpyMessageConsumer - state not reset during receive
Initial Comment:
There are three method signatures for receive in
SpyMessageConsumer that all have the potential to
improperly report "JMSException Another Thread is
already in Receive" due to a prior JMSException (that is
usually recoverable).
For instance, on a heavily loaded machine I've seen the
following error message (notice it eminates from
org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:232)
which will not reset the state of the boolean receiving
variable causing the SECONDARY ERROR FROM
RETRY::::: exception in this stack trace on a retry),
ROOT CAUSE EXCEPTION:::::
WARN 2003-06-18 11:43:10,993 [] JMS Exception
encountered in receiver thread
org.jboss.mq.SpyJMSException: Cannot create a
ConnectionReceiver
at org.jboss.mq.Connection.receive
(Connection.java:764)
at org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:232)
at
com.printcafe.enetwork.message.MessageReceiver$Recei
verThread.run(MessageReceiver.java:337)
at java.lang.Thread.run(Thread.java:479)
linked exception is:
java.rmi.ConnectException: Connection refused to host:
10.34.10.150; nested exception is:
java.net.ConnectException: Connection
refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect
(Native Method)
at java.net.PlainSocketImpl.doConnect
(PlainSocketImpl.java:350)
at java.net.PlainSocketImpl.connectToAddress
(PlainSocketImpl.java:137)
at java.net.PlainSocketImpl.connect
(PlainSocketImpl.java:124)
at java.net.Socket.<init>(Socket.java:268)
at java.net.Socket.<init>(Socket.java:95)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSo
cket(RMIDirectSocketFactory.java:20)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createS
ocket(RMIMasterSocketFactory.java:115)
at
sun.rmi.transport.tcp.TCPEndpoint.newSocket
(TCPEndpoint.java:494)
at
sun.rmi.transport.tcp.TCPChannel.createConnection
(TCPChannel.java:185)
at
sun.rmi.transport.tcp.TCPChannel.newConnection
(TCPChannel.java:169)
at sun.rmi.server.UnicastRef.invoke
(UnicastRef.java:78)
at org.jboss.mq.il.rmi.RMIServerIL_Stub.receive
(Unknown Source)
at org.jboss.mq.Connection.receive
(Connection.java:756)
at org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:232)
at
com.printcafe.enetwork.message.MessageReceiver$Recei
verThread.run(MessageReceiver.java:337)
at java.lang.Thread.run(Thread.java:479)
WARN 2003-06-18 11:43:10,993 [] JMS Exception
encountered in receiver thread
org.jboss.mq.SpyJMSException: Cannot create a
ConnectionReceiver
at org.jboss.mq.Connection.receive
(Connection.java:764)
at org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:232)
at
com.printcafe.enetwork.message.MessageReceiver$Recei
verThread.run(MessageReceiver.java:337)
at java.lang.Thread.run(Thread.java:479)
linked exception is:
java.rmi.ConnectException: Connection refused to host:
10.34.10.150; nested exception is:
java.net.ConnectException: Connection
refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect
(Native Method)
at java.net.PlainSocketImpl.doConnect
(PlainSocketImpl.java:350)
at java.net.PlainSocketImpl.connectToAddress
(PlainSocketImpl.java:137)
at java.net.PlainSocketImpl.connect
(PlainSocketImpl.java:124)
at java.net.Socket.<init>(Socket.java:268)
at java.net.Socket.<init>(Socket.java:95)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSo
cket(RMIDirectSocketFactory.java:20)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createS
ocket(RMIMasterSocketFactory.java:115)
at
sun.rmi.transport.tcp.TCPEndpoint.newSocket
(TCPEndpoint.java:494)
at
sun.rmi.transport.tcp.TCPChannel.createConnection
(TCPChannel.java:185)
at
sun.rmi.transport.tcp.TCPChannel.newConnection
(TCPChannel.java:169)
at sun.rmi.server.UnicastRef.invoke
(UnicastRef.java:78)
at org.jboss.mq.il.rmi.RMIServerIL_Stub.receive
(Unknown Source)
at org.jboss.mq.Connection.receive
(Connection.java:756)
at org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:232)
at
com.printcafe.enetwork.message.MessageReceiver$Recei
verThread.run(MessageReceiver.java:337)
at java.lang.Thread.run(Thread.java:479)
ERROR 2003-06-18 11:43:10,993 []
org.jboss.mq.SpyJMSException: Cannot create a
ConnectionReceiver
at org.jboss.mq.Connection.receive
(Connection.java:764)
at org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:232)
at
com.printcafe.pod.component.queue.PhoenixRetryQueueR
eceive.receiveMsgs(PhoenixRetryQueueReceive.java:30)
at
com.printcafe.pod.component.queue.PhoenixRetryThread.
run(PhoenixRetryThread.java:35)
linked exception is:
java.rmi.ConnectException: Connection refused to host:
10.34.10.150; nested exception is:
java.net.ConnectException: Connection
refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect
(Native Method)
at java.net.PlainSocketImpl.doConnect
(PlainSocketImpl.java:350)
at java.net.PlainSocketImpl.connectToAddress
(PlainSocketImpl.java:137)
at java.net.PlainSocketImpl.connect
(PlainSocketImpl.java:124)
at java.net.Socket.<init>(Socket.java:268)
at java.net.Socket.<init>(Socket.java:95)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSo
cket(RMIDirectSocketFactory.java:20)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createS
ocket(RMIMasterSocketFactory.java:115)
at
sun.rmi.transport.tcp.TCPEndpoint.newSocket
(TCPEndpoint.java:494)
at
sun.rmi.transport.tcp.TCPChannel.createConnection
(TCPChannel.java:185)
at
sun.rmi.transport.tcp.TCPChannel.newConnection
(TCPChannel.java:169)
at sun.rmi.server.UnicastRef.invoke
(UnicastRef.java:78)
at org.jboss.mq.il.rmi.RMIServerIL_Stub.receive
(Unknown Source)
at org.jboss.mq.Connection.receive
(Connection.java:756)
at org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:232)
at
com.printcafe.pod.component.queue.PhoenixRetryQueueR
eceive.receiveMsgs(PhoenixRetryQueueReceive.java:30)
at
com.printcafe.pod.component.queue.PhoenixRetryThread.
run(PhoenixRetryThread.java:35)
SECONDARY ERROR FROM RETRY:::::
WARN 2003-06-18 11:43:17,402 [] JMS Exception
encountered in receiver thread
javax.jms.JMSException: Another thread is already in
receive.
at org.jboss.mq.SpyMessageConsumer.receive
(SpyMessageConsumer.java:219)
at
com.printcafe.enetwork.message.MessageReceiver$Recei
verThread.run(MessageReceiver.java:337)
at java.lang.Thread.run(Thread.java:479)
Here's an example based off of one of the three receive
methods:
Current Code:
public Message receive()
throws JMSException
{
if ( closed )
{
throw new IllegalStateException( "The
MessageConsumer is closed" );
}
synchronized ( stateLock )
{
if ( receiving )
{
throw new JMSException( "Another thread is
already in receive." );
}
if ( listening )
{
throw new JMSException( "A message listener is
already registered" );
}
receiving = true;
}
synchronized ( messages )
{
/*NOTICE if a JMSException gets thrown out of this
method the boolean receiving will never be reset which
will cause the
if ( receiving )
{
throw new JMSException( "Another thread is
already in receive." );
}
Logic to be invoked on subsequent attempts to call this
method on this object*/
SpyMessage msg = session.connection.receive(
subscription, 0 );
if ( msg != null )
{
Message mes = preProcessMessage( msg );
if ( mes != null )
{
synchronized ( stateLock )
{
receiving = false;
}
return mes;
}
}
try
{
waitingForMessage = true;
while ( true )
{
if ( closed )
{
return null;
}
Message mes = getMessage();
if ( mes != null )
{
return mes;
}
if( log.isTraceEnabled() )
log.trace("receive in messages.wait()");
messages.wait();
}
}
catch ( InterruptedException e )
{
JMSException newE = new SpyJMSException
( "Receive interupted" );
newE.setLinkedException( e );
throw newE;
}
finally
{
waitingForMessage = false;
synchronized ( stateLock )
{
receiving = false;
}
}
}
}
Patched Code:
public Message receive()
throws JMSException
{
if ( closed )
{
throw new IllegalStateException( "The
MessageConsumer is closed" );
}
synchronized ( stateLock )
{
if ( receiving )
{
throw new JMSException( "Another thread is
already in receive." );
}
if ( listening )
{
throw new JMSException( "A message listener is
already registered" );
}
receiving = true;
}
synchronized ( messages )
{
/*I moved the try so that if a JMSException occurs in
the following lines that the receiving boolean will
properly be reset in the finally clause*/
try{
SpyMessage msg = session.connection.receive(
subscription, 0 );
if ( msg != null )
{
Message mes = preProcessMessage( msg );
if ( mes != null )
{
synchronized ( stateLock )
{
receiving = false;
}
return mes;
}
}
waitingForMessage = true;
while ( true )
{
if ( closed )
{
return null;
}
Message mes = getMessage();
if ( mes != null )
{
return mes;
}
if( log.isTraceEnabled() )
log.trace("receive in messages.wait()");
messages.wait();
}
}
catch ( InterruptedException e )
{
JMSException newE = new SpyJMSException
( "Receive interupted" );
newE.setLinkedException( e );
throw newE;
}
finally
{
waitingForMessage = false;
synchronized ( stateLock )
{
receiving = false;
}
}
}//end sync block
}
Please feel free to contact me with questions or
problems regarding this error condition.
Thanks.
-Dennis Kremer
[EMAIL PROTECTED]
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376687&aid=758059&group_id=22866
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development