You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by activemqnewbie <ac...@yahoo.co.in> on 2008/01/22 17:23:39 UTC
Consumer is closed Exception
Subscriber closes with an exception(below)after consuming certain
messages.This happens at different intervals.
Appreciate if someone could let me know the reason and solution for this.
Am using activemq 5.0,java 5.
Is there any property/setting that i need to do ?
Below is the stack trace.
<ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
Notifying/signaling a waiting thread... <ERROR><2008/01/10
10:43:23.144><21621663><> ExceptionListener receives a JMS exception
<TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
javax.jms.IllegalStateException: The Consumer is closed at
org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
at
org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
Thanks
--
View this message in context: http://www.nabble.com/Consumer-is-closed-Exception-tp15022223s2354p15022223.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Consumer is closed Exception
Posted by activemqnewbie <ac...@yahoo.co.in>.
Below is the complete stack trace.
<ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
JMS exception
<TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering Message
Listener...
<TRACE><2008/01/10 10:43:23.127><21621663><> Notifying/signaling a waiting
thread...
<ERROR><2008/01/10 10:43:23.144><21621663><> ExceptionListener receives a
JMS exception
<TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
Listener...
<ERROR><2008/01/10 10:43:23.153><21621663><>
javax.jms.IllegalStateException: The Consumer is closed
at
org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
at
org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
at
ss.integration.util.MessageConsumer.unregisterListener(MessageConsumer.java:205)
at
ss.integration.util.MessageConsumer.notifyWaitingThread(MessageConsumer.java:159)
at ss.integration.util.ExListener.onException(ExListener.java:26)
at
org.apache.activemq.ActiveMQConnection$3.run(ActiveMQConnection.java:1648)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
<TRACE><2008/01/10 10:43:23.153><21621663><> Notifying/signaling a waiting
thread...
<TRACE><2008/01/10 10:43:23.154><32019423><> Waiting thread awaken
<TRACE><2008/01/10 10:43:23.155><32019423><> closing subscriber...
<TRACE><2008/01/10 10:43:23.156><32019423><> subscriber closed
<TRACE><2008/01/10 10:43:23.156><32019423><> closing session...
<TRACE><2008/01/10 10:43:23.156><32019423><> session closed
<TRACE><2008/01/10 10:43:23.156><32019423><> closing topic connection...
<TRACE><2008/01/10 10:43:23.158><32019423><> Exception in close()
<TRACE><2008/01/10 10:43:23.158><32019423><> closing topic connection...
<TRACE><2008/01/10 10:43:23.159><32019423><> Exception in close()
<ERROR><2008/01/10 10:43:23.159><32019423><> Unable to connect to the JMS
Server
<ERROR><2008/01/10 10:43:23.159><32019423><> Error in MessageConsumer.start:
Unable to connect to the JMS Server
<TRACE><2008/01/10 10:43:23.160><32019423><> closing topic connection...
<TRACE><2008/01/10 10:43:23.160><32019423><> Exception in close()
<ERROR><2008/01/10 10:43:23.161><32019423><> Error in main: Unable to
connect to the JMS Server
<ERROR><2008/01/10 10:43:23.161><32019423><> StackTrace:
<ERROR><2008/01/10 10:43:23.163><32019423><>
Error Code: -1
ss.util.SystemException: Unable to connect to the JMS Server
at
ss.integration.util.MessageConsumer.startConnection(MessageConsumer.java:368)
at ss.integration.util.MessageConsumer.start(MessageConsumer.java:124)
at ss.integration.agent.sams.SInputStarter.start(SInputStarter.java:113)
at ss.integration.agent.sams.SInputStarter.main(SInputStarter.java:45)
activemqnewbie wrote:
>
> Subscriber closes with an exception(below)after consuming certain
> messages.This happens at different intervals.
> Appreciate if someone could let me know the reason and solution for this.
> Am using activemq 5.0,java 5.
> Is there any property/setting that i need to do ?
> Below is the stack trace.
> <ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
> JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
> Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
> Notifying/signaling a waiting thread... <ERROR><2008/01/10
> 10:43:23.144><21621663><> ExceptionListener receives a JMS exception
> <TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
> Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
> javax.jms.IllegalStateException: The Consumer is closed at
> org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
> at
> org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
>
>
> Thanks
>
>
--
View this message in context: http://www.nabble.com/Consumer-is-closed-Exception-tp15022223s2354p15023961.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Consumer is closed Exception
Posted by activemqnewbie <ac...@yahoo.co.in>.
Below is the source for MessageConsumer.java
package ss.integration.util;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicConnection;
import javax.jms.Topic;
import javax.jms.TopicSession;
import javax.jms.TopicSubscriber;
import javax.jms.MessageListener;
import javax.jms.JMSException;
import ss.util.logging.Logger;
import ss.util.SystemException;
import ss.util.JNDILookup;
import ss.integration.util.ExListener;
public class MessageConsumer
{
private TopicConnectionFactory _topicConnectionFactory;
private TopicConnection _topicConnection;
private Topic _topic;
private TopicSession _session;
private TopicSubscriber _subscriber;
private String _strClientID;
private String _strTopicConnectionFactory;
private String _strTopic;
private String _strSelector;
private String _strContext;
private String _strURL;
private int _reconnectRetry;
private long _reconnectTime;
private boolean _firstTimeConnection;
// flag to indicated that a shutdown has been requested
private boolean _shutdownRequested;
private static ExListener _exListener;
private static MessageListener _msgListener;
public MessageConsumer(String clientID_,
String topicConnectionFactory_,
String topic_,
String selector_,
String context_,
String url_) throws SystemException
{
_strClientID = clientID_;
_strTopicConnectionFactory = topicConnectionFactory_;
_strTopic = topic_;
_strSelector = selector_;
_strContext = context_;
_strURL = url_;
_exListener = null;
_msgListener = null;
_reconnectRetry = 0; // reconnect is currently not used.
_reconnectTime = 1 * 1000;
_firstTimeConnection = true;
_shutdownRequested = false;
}
public void init() throws SystemException
{
try
{
Logger.trace("MessageConsumer, setting the topicConnection,
client: " + _strClientID);
_topicConnectionFactory =
(TopicConnectionFactory)JNDILookup.lookup(_strTopicConnectionFactory,
_strContext, _strURL);
_topicConnection =
_topicConnectionFactory.createTopicConnection();
_topicConnection.setClientID(_strClientID);
_topic = (Topic)JNDILookup.lookup(_strTopic, _strContext,
_strURL);
_session = _topicConnection.createTopicSession(true, 0);
_subscriber = _session.createDurableSubscriber(_topic,
_strClientID,
_strSelector,
true);
Logger.trace("_topic=" + _topic + " _strClientID=" + _strClientID +
" _strSelector = " + _strSelector);
Logger.trace("_subscriber=" + _subscriber);
if (_exListener == null)
{
_exListener = new ExListener(this);
}
}
catch (JMSException je)
{
Logger.trace("MessageConsumer init() failed: JMSException");
throw new SystemException(je);
}
catch (SystemException se)
{
Logger.trace("MessageConsumer init() failed: SystemException");
throw new SystemException(se);
}
catch (Exception e)
{
Logger.trace("MessageConsumer init() failed: Exception");
throw new SystemException(e);
}
}
public void start() throws SystemException
{
synchronized (this)
{
while (!_shutdownRequested)
{
try
{
startConnection();
Logger.trace("Wait()..." );
wait();
Logger.trace("Waiting thread awaken" );
}
catch (Exception e)
{
Logger.error("Error in MessageConsumer.start: " +
e.getMessage());
throw new SystemException(e);
}
finally
{
close();
}
}
}
}
private void signalShutdown()
{
Logger.trace("Shutting down...");
_shutdownRequested = true;
notifyWaitingThread();
}
// to signal a waiting thread (waiting inside start() method)
public synchronized void notifyWaitingThread()
{
unregisterListener();
Logger.trace("Notifying/signaling a waiting thread...");
notify();
}
public void setListener (MessageListener listener_)
{
_msgListener = listener_;
}
private void registerMsgListener() throws SystemException
{
if (_msgListener != null)
{
try
{
Logger.trace("Registering Message Listener...");
// install asynchronous listener
_subscriber.setMessageListener(_msgListener);
}
catch (JMSException je)
{
throw new SystemException(je);
}
catch (Exception e)
{
throw new SystemException(e);
}
}
else
{
Logger.warning("MessageListener is null");
}
}
private void unregisterListener()
{
try
{
Logger.trace("Unregistering Message Listener...");
_subscriber.setMessageListener(null);
}
catch (Exception e)
{
Logger.error(e);
}
}
private void registerExceptionListener() throws SystemException
{
if (_exListener != null)
{
try
{
Logger.trace("Registering JMS Exception Listener...");
// install asynchronous listener
_topicConnection.setExceptionListener(_exListener);
}
catch (JMSException je)
{
throw new SystemException(je);
}
catch (Exception e)
{
throw new SystemException(e);
}
}
else
{
Logger.warning("ExceptionListener is null");
}
}
public void doCommit () throws SystemException
{
try
{
_session.commit();
}
catch (JMSException je)
{
throw new SystemException(je);
}
catch (Exception e)
{
throw new SystemException(e);
}
}
public void doRollback () throws SystemException
{
try
{
Logger.trace("doRollback() Rolling-back message...");
_session.rollback(); // Be careful
when using this. Sometimes the rollback doesn't work.
Logger.trace("doRollback() Message rolled-back");
signalShutdown();
}
catch (JMSException je)
{
Logger.trace("doRollback() JMS Exception: " + je.getMessage());
throw new SystemException(je);
}
catch (Exception e)
{
Logger.trace("doRollback() Exception :" + e.getMessage());
throw new SystemException(e);
}
}
public void close() throws SystemException
{
try
{
if (_subscriber != null)
{
Logger.trace("closing subscriber...");
_subscriber.close();
_subscriber = null;
Logger.trace("subscriber closed");
}
if (_session != null)
{
Logger.trace("closing session...");
_session.close();
_session = null;
Logger.trace("session closed");
}
if (_topicConnection != null)
{
Logger.trace("closing topic connection...");
_topicConnection.close();
_topicConnection = null;
Logger.trace("topicConnection closed");
}
_topicConnectionFactory = null;
_topic = null;
}
catch (Exception e)
{
Logger.trace("Exception in close()");
}
}
private void startConnection() throws SystemException
{
boolean success = false;
for (int i=0; i<_reconnectRetry || _firstTimeConnection; i++)
{
_firstTimeConnection = false;
try
{
Logger.trace("Closing all connections... ");
close();
if (_exListener != null)
{
wait(_reconnectTime);
}
Logger.trace("Starting all connections... (" + (i+1) + "/" +
_reconnectRetry + ")");
init();
Logger.trace("Init successfull");
registerMsgListener();
Logger.trace("RegisterMsgListener successfull");
registerExceptionListener();
Logger.trace("RegisterExceptionListener successfull");
Logger.trace("Starting TopicConnection...");
_topicConnection.start();
Logger.trace("TopicConnection started...");
success = true;
break;
}
catch (Exception e)
{
Logger.error("startConnection() failed");
Logger.error(e);
}
}
if (!success)
{
close();
Logger.error("Unable to connect to the JMS Server");
throw new SystemException("Unable to connect to the JMS
Server");
}
}
}
activemqnewbie wrote:
>
> Subscriber closes with an exception(below)after consuming certain
> messages.This happens at different intervals.
> Appreciate if someone could let me know the reason and solution for this.
> Am using activemq 5.0,java 5.
> Is there any property/setting that i need to do ?
> Below is the stack trace.
> <ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
> JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
> Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
> Notifying/signaling a waiting thread... <ERROR><2008/01/10
> 10:43:23.144><21621663><> ExceptionListener receives a JMS exception
> <TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
> Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
> javax.jms.IllegalStateException: The Consumer is closed at
> org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
> at
> org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
>
>
> Thanks
>
>
--
View this message in context: http://www.nabble.com/Consumer-is-closed-Exception-tp15022223s2354p15023988.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Consumer is closed Exception
Posted by activemqnewbie <ac...@yahoo.co.in>.
Appreciate if someone could help me solve the isuue.
Thansk
activemqnewbie wrote:
>
> Subscriber closes with an exception(below)after consuming certain
> messages.This happens at different intervals.
> Appreciate if someone could let me know the reason and solution for this.
> Am using activemq 5.0,java 5.
> Is there any property/setting that i need to do ?
> Below is the stack trace.
> <ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
> JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
> Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
> Notifying/signaling a waiting thread... <ERROR><2008/01/10
> 10:43:23.144><21621663><> ExceptionListener receives a JMS exception
> <TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
> Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
> javax.jms.IllegalStateException: The Consumer is closed at
> org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
> at
> org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
>
>
> Thanks
>
>
--
View this message in context: http://www.nabble.com/Consumer-is-closed-Exception-tp15022223s2354p15075290.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Consumer is closed Exception
Posted by James Strachan <ja...@gmail.com>.
On 22/01/2008, activemqnewbie <ac...@yahoo.co.in> wrote:
>
> Subscriber closes with an exception(below)after consuming certain
> messages.This happens at different intervals.
> Appreciate if someone could let me know the reason and solution for this.
Looks like someone is closing the connection/session/consumer under the covers
> Am using activemq 5.0,java 5.
> Is there any property/setting that i need to do ?
> Below is the stack trace.
> <ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
> JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
> Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
> Notifying/signaling a waiting thread... <ERROR><2008/01/10
> 10:43:23.144><21621663><> ExceptionListener receives a JMS exception
> <TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
> Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
> javax.jms.IllegalStateException: The Consumer is closed at
> org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
> at
> org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
Whats the full stack trace?
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: Consumer is closed Exception
Posted by James Strachan <ja...@gmail.com>.
On 22/01/2008, activemqnewbie <ac...@yahoo.co.in> wrote:
>
>
> As specified in previous posting,
> Below is the stack trace.
> <ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
> JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
> Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
> Notifying/signaling a waiting thread... <ERROR><2008/01/10
> 10:43:23.144><21621663><> ExceptionListener receives a JMS exception
> <TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
> Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
> javax.jms.IllegalStateException: The Consumer is closed at
> org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
> at
> org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
Whats the full stack trace? i.e. whats after this line
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: Consumer is closed Exception
Posted by activemqnewbie <ac...@yahoo.co.in>.
As specified in previous posting,
Below is the stack trace.
<ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
Notifying/signaling a waiting thread... <ERROR><2008/01/10
10:43:23.144><21621663><> ExceptionListener receives a JMS exception
<TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
javax.jms.IllegalStateException: The Consumer is closed at
org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
at
org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
Thabks
activemqnewbie wrote:
>
> Subscriber closes with an exception(below)after consuming certain
> messages.This happens at different intervals.
> Appreciate if someone could let me know the reason and solution for this.
> Am using activemq 5.0,java 5.
> Is there any property/setting that i need to do ?
> Below is the stack trace.
> <ERROR><2008/01/10 10:43:23.127><21621663><> ExceptionListener receives a
> JMS exception <TRACE><2008/01/10 10:43:23.127><21621663><> Unregistering
> Message Listener... <TRACE><2008/01/10 10:43:23.127><21621663><>
> Notifying/signaling a waiting thread... <ERROR><2008/01/10
> 10:43:23.144><21621663><> ExceptionListener receives a JMS exception
> <TRACE><2008/01/10 10:43:23.144><21621663><> Unregistering Message
> Listener... <ERROR><2008/01/10 10:43:23.153><21621663><>
> javax.jms.IllegalStateException: The Consumer is closed at
> org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:679)
> at
> org.apache.activemq.ActiveMQMessageConsumer.setMessageListener(ActiveMQMessageConsumer.java:352)
>
>
> Thanks
>
>
--
View this message in context: http://www.nabble.com/Consumer-is-closed-Exception-tp15022223s2354p15023049.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.