pulsar4s icon indicating copy to clipboard operation
pulsar4s copied to clipboard

negativeAcknowledge

Open colinbes opened this issue 4 years ago • 1 comments

If on consumer.receive we get a failed Try does one need to call consumer.negativeAcknowledge?

If so then how does one do this as we would only have the exception and not the consumer method? For example. with code below what would we reference in consumer.negativeAcknowledge(??) as msg is Try[CosumerMessage[String]]

    val msg = consumer.receive

    msg match {
      case Success(value) =>
        println(s"${consumer.subscription} Success, $label ${value.valueTry}")
        consumer.acknowledge(value)
      case Failure(exception) =>
        println(s"Failed: ${exception.getMessage}")
        consumer.negativeAcknowledge(??)
    }

colinbes avatar Dec 11 '20 18:12 colinbes

Are you encountering a situation where failures lead to unacknowledged messages? If so that's likely a bug.

If you don't receive a message back that typically means there was an error receiving the message for some reason (e.g. the client is disconnected or closed). It's not your responsibility to acknowledge anything. The correct way to recover really depends on the type of error, but one possible strategy is to restart the consumer with an exponential backoff, then fail after some amount of time.

gmethvin avatar Dec 29 '20 23:12 gmethvin