diff --git a/core/src/main/resources/reference.conf b/core/src/main/resources/reference.conf index 2e49eac8..3607aa41 100644 --- a/core/src/main/resources/reference.conf +++ b/core/src/main/resources/reference.conf @@ -38,7 +38,7 @@ avastRabbitMQConsumerDefaults { // queueName = "test" - processTimeout = 10s + processTimeout = 10s // 0 for disable the timeout prefetchCount = 100 diff --git a/core/src/main/scala/com/avast/clients/rabbitmq/DefaultRabbitMQClientFactory.scala b/core/src/main/scala/com/avast/clients/rabbitmq/DefaultRabbitMQClientFactory.scala index 6d44c926..b304e29f 100644 --- a/core/src/main/scala/com/avast/clients/rabbitmq/DefaultRabbitMQClientFactory.scala +++ b/core/src/main/scala/com/avast/clients/rabbitmq/DefaultRabbitMQClientFactory.scala @@ -520,8 +520,13 @@ private[rabbitmq] object DefaultRabbitMQClientFactory extends LazyLogging { .map(Task.fromEffect[F, DeliveryResult]) .flatten - action - .timeout(ScalaDuration(processTimeout.toMillis, TimeUnit.MILLISECONDS)) + val timedOutAction = if (processTimeout == Duration.ZERO) { + action + } else { + action.timeout(ScalaDuration(processTimeout.toMillis, TimeUnit.MILLISECONDS)) + } + + timedOutAction .onErrorRecoverWith { case e: TimeoutException => timeoutsMeter.mark()