question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Client] JSONSchema not able to encode message in case class (scala)

See original GitHub issue

Client Library version: 2.5.0

Describe the bug The producer is not able to produce JSON data with the content of the case class. Only empty values are getting passed to the broker. This is primarily because the JSON encoder not able to encode the message properly.

Code snippet

case class Student(name: String, roll: Int)

val client: PulsarClient = PulsarClient.builder()
    .serviceUrl("pulsar://localhost:6650")
    .build();

  val producer = client.newProducer(JSONSchema.of(classOf[Student]))
    .topic("foobar")
    .sendTimeout(3, TimeUnit.SECONDS).create

  def produce(msg: Student) = {
    producer.send(msg)
  }

Expected behavior Should encode the data available in case class and send it to the broker for the pulsar consumer.

Desktop (please complete the following information):

  • Mac: [e.g. iOS]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jiazhaicommented, Feb 12, 2020

@yjshen Would you please help take a look when you have time?

0reactions
babatushcommented, Feb 14, 2022

Can someone close this issue? @yjshen solution works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSONSchema values not sent when using Scala Case class
I have a Scala Kafka Producer code where I am using a case class to initialize values and trying to send it using...
Read more >
endpoints4s/endpoints4s - Gitter
Getting circe encoder out of JsonSchema is possible, but the other way? ... wasn't aware of this message, I started working ond #283...
Read more >
JSON Schema Serializer and Deserializer
This document describes how to use JSON Schema with the Apache Kafka® Java client and console tools. Both the JSON Schema serializer and...
Read more >
JSON Schemas - endpoints4s
sealed trait Shape case class Circle(radius: Double) extends Shape case class ... A possible JSON schema for this data type consists in using...
Read more >
JSON - Wikipedia
Any valid JSON file is a valid JavaScript ( .js ) file, even though it makes no changes to a web page on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found