1
resposta

Ajuda com a classe EmailService

Estou criando as mesmas classes que o instrutor criou em cada aula. Já comparei o conteúdo das classes com as fornecidas pelo instrutor e estão iguais. No entanto, ao tentar rodar a EmailService, está dando o seguinte exception:

Exception in thread "main" org.apache.kafka.common.errors.SerializationException: Error deserializing key/value for partition ECOMMERCE_SEND_EMAIL-0 at offset 20. If needed, please seek past the record to continue consumption. Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 path $ at com.google.gson.Gson.fromJson(Gson.java:944) at com.google.gson.Gson.fromJson(Gson.java:897) at com.google.gson.Gson.fromJson(Gson.java:846) at com.google.gson.Gson.fromJson(Gson.java:817) at br.com.alura.ecommerce.GsonDeserializer.deserialize(GsonDeserializer.java:29) at org.apache.kafka.common.serialization.Deserializer.deserialize(Deserializer.java:60) at org.apache.kafka.clients.consumer.internals.Fetcher.parseRecord(Fetcher.java:1268) at org.apache.kafka.clients.consumer.internals.Fetcher.access$3600(Fetcher.java:124) at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.fetchRecords(Fetcher.java:1492) at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.access$1600(Fetcher.java:1332) at org.apache.kafka.clients.consumer.internals.Fetcher.fetchRecords(Fetcher.java:645) at org.apache.kafka.clients.consumer.internals.Fetcher.fetchedRecords(Fetcher.java:606) at org.apache.kafka.clients.consumer.KafkaConsumer.pollForFetches(KafkaConsumer.java:1294) at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1225) at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1201) at br.com.alura.ecommerce.KafkaService.run(KafkaService.java:37) at br.com.alura.ecommerce.EmailService.main(EmailService.java:22) Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 path $ at com.google.gson.stream.JsonReader.nextString(JsonReader.java:826) at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:402) at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:390) at com.google.gson.Gson.fromJson(Gson.java:932) ... 16 more

Não consigo encontrar onde está o erro. Por favor, alguém poderia me ajudar?

1 resposta

Opa, Mauricio, posta o código da sua classe EmailService.