diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java index 028b6c84f0..1bb8d38d14 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java @@ -72,7 +72,7 @@ public final class ActiveMQClient { public static final long DEFAULT_CALL_TIMEOUT = 30000; - public static final long DEFAULT_CALL_FAILOVER_TIMEOUT = -1; + public static final long DEFAULT_CALL_FAILOVER_TIMEOUT = 30000; public static final int DEFAULT_ACK_BATCH_SIZE = 1024 * 1024; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java index f0543d1cda..c23e9bbd12 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java @@ -227,4 +227,7 @@ public interface ActiveMQClientMessageBundle { @Message(id = 119060, value = "Large Message Transmission interrupted on consumer shutdown.") ActiveMQLargeMessageInterruptedException largeMessageInterrupted(); + + @Message(id = 119061, value = "Cannot send a packet while channel is failing over.") + IllegalStateException cannotSendPacketDuringFailover(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java index 373bfa4e97..57ed1e8474 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java @@ -228,9 +228,15 @@ public final class ChannelImpl implements Channel { try { if (failingOver) { - // TODO - don't hardcode this timeout try { - failoverCondition.await(10000, TimeUnit.MILLISECONDS); + if (connection.getBlockingCallFailoverTimeout() < 0) { + failoverCondition.await(); + } + else { + if (!failoverCondition.await(connection.getBlockingCallFailoverTimeout(), TimeUnit.MILLISECONDS)) { + ActiveMQClientLogger.LOGGER.debug("timed-out waiting for fail-over condition on non-blocking send"); + } + } } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); @@ -239,7 +245,7 @@ public final class ChannelImpl implements Channel { // Sanity check if (transferring) { - throw new IllegalStateException("Cannot send a packet while channel is doing failover"); + throw ActiveMQClientMessageBundle.BUNDLE.cannotSendPacketDuringFailover(); } if (resendCache != null && packet.isRequiresConfirmations()) { @@ -302,7 +308,7 @@ public final class ChannelImpl implements Channel { } else { if (!failoverCondition.await(connection.getBlockingCallFailoverTimeout(), TimeUnit.MILLISECONDS)) { - ActiveMQClientLogger.LOGGER.debug("timed-out waiting for failover condition"); + ActiveMQClientLogger.LOGGER.debug("timed-out waiting for fail-over condition on blocking send"); } } }