8000 Merge pull request #97 from rabbitmq/rabbitmq-java-client-57 · liborange/rabbitmq-java-client@423a760 · GitHub
[go: up one dir, main page]

Skip to content

Commit 423a760

Browse files
Merge pull request rabbitmq#97 from rabbitmq/rabbitmq-java-client-57
Make sure missed heartbeats trigger connection recovery
2 parents f24b66f + ffb2559 commit 423a760

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
/.idea/
1313
/build/
1414
/cover/
15+
/debug/
1516
/dist/
1617
/ebin/
1718
/out/
1819
/tmp/
19-
junit*.properties
20+
junit*.properties

src/com/rabbitmq/client/impl/recovery/AutorecoveringConnection.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.rabbitmq.client.BlockedListener;
66
import com.rabbitmq.client.Channel;
77
import com.rabbitmq.client.Connection;
8+
import com.rabbitmq.client.MissedHeartbeatException;
89
import com.rabbitmq.client.Recoverable;
910
import com.rabbitmq.client.RecoveryListener;
1011
import com.rabbitmq.client.ShutdownListener;
@@ -378,7 +379,7 @@ private void addAutomaticRecoveryListener() {
378379
ShutdownListener automaticRecoveryListener = new ShutdownListener() {
379380
public void shutdownCompleted(ShutdownSignalException cause) {
380381
try {
381-
if (!cause.isInitiatedByApplication()) {
382+
if (shouldTriggerConnectionRecovery(cause)) {
382383
c.beginAutomaticRecovery();
383384
}
384385
} catch (Exception e) {
@@ -394,6 +395,10 @@ public void shutdownCompleted(ShutdownSignalException cause) {
394395
}
395396
}
396397

398+
protected boolean shouldTriggerConnectionRecovery(ShutdownSignalException cause) {
399+
return !cause.isInitiatedByApplication() || (cause.getCause() instanceof MissedHeartbeatException);
400+
}
401+
397402
/**
398403
* Not part of the public API. Mean to be used by JVM RabbitMQ clients that build on
399404
* top of the Java client and need to be notified when server-named queue name changes

0 commit comments

Comments
 (0)
0