How to restart the stopped Actor?

Hi everyone,

We somehow fall into this NonFatal exception, we can see its log.
Then the consumer gets stopped and doesn’t restart itself. It stays shut.

Can anyone help why it may occur and maybe we can solve it?
Or, as a quick workaround, at least how can we auto-restart it?

We have this code in supervisor but it doesn’t help:

case ex: Exception =>
Restart

Here is the log message we get:
[6baf9] Exception when polling from consumer, stopping actor: org.apache.kafka.common.KafkaException: Unexpected error from SyncGroup: The server experienced an unexpected error when processing the request.

I see the actor is stopping itself after logging the exception / error.

The code in the supervisor will work if an exception is thrown, I would guess.

So instead of stopping the actor after logging the exception, how about you instead re-throw the exception? Then the supervision should see it, I imagine.

Hi Emre,

I’m don’t know what you are doing, but Alpakka Kafka’s KafkaConsumerActor is not meant to be interacted with directly. It is managed from the Akka Streams stages in Alpakka Kafka. Errors in the Kafka Consumer interaction will stop the stream.
To handle these failures you may wrap the stream in a RestartSource as shown in https://doc.akka.io/docs/alpakka-kafka/current/errorhandling.html

Cheers,
Enno.

1 Like

Thank you @ennru, I will try and let you know about it.

@ennru

it still stops :confused:

UPDATE:

This behavior was caused by our VM options. When we reach the memory limit we observed that the Akka actor was stopping itself.

Just a quick heads up for anyone wondering and/or searching for a possible solution.