[rabbitmq-discuss] Java client problem
jacek_
jacekolszak at gmail.com
Thu May 27 13:07:40 BST 2010
Hi,
I am testing currently the Java RabbitMQ client. I want to make sure that
any problems that can occur with connection to RabbitMQ server will be
handled properly. To test if everything is working fine I stopped rabbitmq
server proces (using kill -s SIGSTOP command). This imitate more or less
problems which can occur in the future. I specified the heartbeat in Java
client and want to get exceptions when the server does not respond.
Unfortunatelly when the client tries to connect it enters into endless loop.
The socket timeout exception is thrown by standard Java socket mechanism but
RabbitMQ client catch this exception and retry. No MissedHeartbeatException
exception is thrown. I have looked into source code of AMQConnection class
and found that method:
public void handleSocketTimeout() throws MissedHeartbeatException {
if (_heartbeat == 0) {
// No heartbeating. Go back and wait some more.
return;
}
_missedHeartbeats++;
// We check against 8 = 2 * 4 because we need to wait for at
// least two complete heartbeat setting intervals before
// complaining, and we've set the socket timeout to a quarter
// of the heartbeat setting in setHeartbeat above.
if (_missedHeartbeats > (2 * 4)) {
throw new MissedHeartbeatException("Heartbeat missing with
heartbeat == " +
_heartbeat + " seconds");
}
}
The problem is that _heartbeat field is filled with data after connection is
created (not before). The initial value is 0. Until connection is
successfully made client will try to connect again and again. Exception will
never be thrown, so my application will have no information about server
problems. In my opinion only minor changes are required to make this thing
work - _hearbeat field should be filled before making the connection. Please
correct me if I am wrong.
Thanks in advance,
Jacek
--
View this message in context: http://old.nabble.com/Java-client-problem-tp28693038p28693038.html
Sent from the RabbitMQ mailing list archive at Nabble.com.
More information about the rabbitmq-discuss
mailing list