SpinGo / op-rabbit

The Opinionated RabbitMQ Library for Scala and Akka
Other
232 stars 73 forks source link

Getting [akka://my-app/user/cluster/rabbit-control/connection] null and unable to restore it #159

Open afrancoc2000 opened 6 years ago

afrancoc2000 commented 6 years ago

Hi,

I've been working on an implementation of akka.cluster inside kubernetes using rabbit for some queues I need to use to consume and produce some messages. I found out, that I need to initialize the connection, like 30 seconds after the cluster is formed to get a healthy connection and if I don't wait all this time the connection is not established.

the only thing I get is a warning saying:

[akka://my-app/user/cluster/rabbit-control/connection] null

But I don't get any exceptions or errors that I can track.

I tried stablishing a supervision strategy from the actor that creates de rabbit control like this:

override val supervisorStrategy: OneForOneStrategy =
  OneForOneStrategy(maxNrOfRetries = -1, withinTimeRange = Duration.Inf) {
    case e: Exception =>
      val sw = new StringWriter
      e.printStackTrace(new PrintWriter(sw))
      LogHelper.logger.error(s"Ocurrió un error en un actor del Cluster: ${e.getMessage} \n stacktrace: ${sw.toString}")
      Restart
  }
...
context.actorOf(QueueService.getRabbitControlProps, "rabbit-control")

But, as no exception is thrown then the supervision strategy is never triggered.

I am thinking of creating like a health probe something that checks if messages are being produced and if it fails then restart the RabbitControl actor, but I was wondering if there is something in the library that could help me test this connection, or do you know what is the null in the error? and why isn't there like a nullpointerexception? or how could I scalate this warning to error?

Thanks.

tilmanginzel commented 6 years ago

@afrancoc2000 We use the StatusCheckMessage as a health check in our setup. You can see an example implementation here: https://github.com/SpinGo/op-rabbit/issues/128