Help configuring server connection timeout
Hello I'm running JMS 3.6 SP3 in Windows and I'm trying to configure
the time it takes to generate a
[C4002]: Read packet failed. - cause: java.net.SocketException: Connection reset
message.
I've set up the following configuration, but it takes about 1:45-2:00 minutes to get the message.
Here's the configuration:
imqAddressList=mq://localhost:7676/jms
imqPingInterval=10
imqReconnectAttempts=-1
imqReconnectEnabled=true
imqReconnectInterval=10000
I would like this at around 30 seconds or less if possible.
Any help would be appreciated
Thanks for the reply.
In regards to your queustion I am running as JMS as my configuration.
Here's me queue receiver code that you wanted to look at.
import javax.jms.*;
import javax.naming.NamingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Date;
public class QueueReceiver extends Thread implements ExceptionListener, JMSListener {
String queueName = null;
QueueConnectionFactory queueConnectionFactory = null;
javax.jms.Queue queue = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;
TextListener textListener = null;
// List of listeners that will be started from the calling applications
private List listeners = new ArrayList();
public QueueReceiver(String queueName) {
// Store the queueName
this.queueName = queueName;
} // End of QueueReceiver
public void run() {
createConnection();
} // End of run()
public synchronized void addJMSListener(JMSListener l) {
listeners.add(l);
} // End of addJMSListener
public synchronized void removeJMSListener(JMSListener l) {
listeners.remove(l);
} // End of removeJMSListener
/**
* This event will fire off that something has occurred. This will then
* be picked up from the calling application
* @param message String The message to pass back.
*/
private synchronized void fireJMSEvent(String message) {
JMSEvent jmsEvent = new JMSEvent(this, message);
Iterator eventlisteners = listeners.iterator();
while (eventlisteners.hasNext()) {
((JMSListener) eventlisteners.next()).jmsReceived(jmsEvent);
}
} // End of fireJMSEvent
/**
* This onException event is activated with a JMSException from the JMS Server
* For a complete list of available codes refer to the JavaDevelopers Guide/
* @param e JMSException The exception.
*/
public void onException(JMSException e) {
if (e.getErrorCode() == "C4073") {
fireJMSEvent("Queue in use");
// Kill the Queue
queueConnection.close();
} else{
// This is for all other cases
fireJMSEvent("Network Error");
try{
queueConnection.close();
createConnection();
} catch (Exception ee) {
System.out.println("Attempting reconnection failure");
}
}
} //end onException
/**
* This will catch and throw the JMSEvents received by it.
*
* @param event JMSEvent The JMSEvent
*/
public void jmsReceived(JMSEvent event) {
// This event is from the TextListener stating that a message has been received
if (event.getMessage() == "Message Received") {
fireJMSEvent("Message Received");
}
} //End of jmsEvent
/**
*Create the connectio to the queue
*
*/
public void createConnection(){
boolean bolSkip = false;
if (queueConnectionFactory == null){
try {
queueConnectionFactory = SampleUtilities.getQueueConnectionFactory();
} catch (NamingException e) {
System.out.println("Exception = " + e.getMessage());
fireJMSEvent("Invalid name supplied");
bolSkip = true;
}
}
if (!bolSkip) {
try {
queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.setExceptionListener(this);
queueSession = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
queue = (javax.jms.Queue) SampleUtilities.jndiLookup(queueName);
} catch (JMSException e) {
onException(e);
bolSkip = true;
} catch (Exception e) {
fireJMSEvent("Server not available");
bolSkip = true;
}
/*
* Create session and receiver.
* Register message listener (TextListener).
* Start message delivery; listener displays the message obtained.
* Only do this if everything above was ok.
*/
if (!bolSkip) {
try {
queueReceiver = queueSession.createReceiver(queue);
textListener = new TextListener();
textListener.addJMSListener(this);
queueReceiver.setMessageListener(textListener);
queueConnection.start();
// if successful to this point send back to calling app that the server is set up
fireJMSEvent("Server Started");
} catch (JMSException e) {
onException(e);
}
}
}
}
} // End of Class QueueReceiver
By the way what is the latest version of JMS for Windows?