Reconnection to a receive queue after a network failure
Hello I have an issue that I have been trying to resolve.
For a remote application trying to connection to a JMS server on another machine, if there is a network failure, I can't get it to reconnect with the previously established queue and receive any messages. Just to let you know I do not currently have the enterprise edition.
Here is the recieve code that I currently have.
public void run() {
try {
queueConnectionFactory =
SampleUtilities.getQueueConnectionFactory();
queueConnection =
queueConnectionFactory.createQueueConnection();
queueConnection.setExceptionListener(this);
queueSession = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
queue = (Queue) SampleUtilities.jndiLookup(queueName);
queue = (javax.jms.Queue) SampleUtilities.jndiLookup(queueName);
} catch (JMSException e) {
fireJMSEvent("JMS Exception");
} catch (NamingException e) {
fireJMSEvent("Invalid name supplied");
} catch (NullPointerException e) {
fireJMSEvent("No name supplied");
} catch (Exception e) {
fireJMSEvent("Server not available");
}
/*
* Create session and receiver.
* Register message listener (TextListener).
* Start message delivery; listener displays the message obtained.
*/
try {
if (queue != null) {
queueReceiver = queueSession.createReceiver(queue);
textListener = new TextListener();
queueReceiver.setMessageListener(textListener);
queueConnection.start();
// if successful to this point send back to calling app that the server is set up
fireJMSEvent("Server Started");
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println(e.toString());
}
}
}
} catch (JMSException e) {
onException(e);
} finally {
if (queueConnection != null) {
try {
queueConnection.close();
} catch (JMSException e) {
onException(e);
}
}
}
} // End of run()
Can anybody help me?
Thanks in advance

