-
1. Re: Problem in topic consumers when lost connections
clebert.suconic Dec 2, 2008 12:25 PM (in response to cbolanos)My problem is that when the stand alone client reconects after lossing connection with the Jboss server, (something that is very probably, because they connect through internet) it can sends messages to the queue but it cannot consume messages from the topic.
It is not clear to me how you are reconnecting your clients. Can you elaborate on that please? -
2. Re: Problem in topic consumers when lost connections
cbolanos Dec 3, 2008 4:21 AM (in response to cbolanos)Thank you very much for replaying...
Well, really I'm not reconecting in my code. When phisical connection goes down, then I can see warn messages from LeasePinger, and when the client recovers its connection warn messages don't appear. In this situation, the client can send again messages to the queue, but cannot receive messages from the topic.
This is a extract of my code, from the client's GUI you call the send information method, and the AVListener's onMessage method only prints the information received on that GUI.
...
public void run()
{
try
{
initConnections();
startTopicListener();
status = RUNNING;
while(status == RUNNING)
{
try
{
synchronized (this)
{
this.wait(10000);
}
}
catch(InterruptedException ie)
{
ie.printStackTrace();
}
}//while
}//try
catch(Exception e)
{
e.printStackTrace();
}//catch
finally
{
finishTopicListener();
finishConnections();
}
}
public void sendInformation(Object info) throws Exception
{
Queue queue = (Queue)ic.lookup(destinationName);
MessageProducer sender = qsession.createProducer(queue);
TextMessage message = qsession.createTextMessage(info.toString());
message.setStringProperty(propClientId, clientId);
sender.send(message);
}
public void initConnections() throws Exception
{
ic = new InitialContext();
ConnectionFactory cf = null;
cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
connection = cf.createConnection(jmsUser, jmsPwd);
//Obligatorio indicar clientid para poder crear una durable suscription
connection.setClientID(clientId);
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
qsession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
public void startTopicListener() throws Exception
{
Topic topic = (Topic)ic.lookup(topicName);
subscriber = session.createDurableSubscriber(topic, subscriptionName);
avListener = new AVTopicListener();
subscriber.setMessageListener(avListener);
connection.start();
}
public void finishConnections() throws Exception
{
if (connection != null)
{
connection.close();
}
if (ic != null)
{
ic.close();
}
}
public void finishTopicListener() throws Exception
{
subscriber.close();
session.close();
qsession.close();
}
...