0

I have the following code:

private Properties getStreamProperties(String suffix) {
        Properties streamsConfiguration = new Properties();
        streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, groupId + "-" + suffix);
        streamsConfiguration.put(StreamsConfig.CLIENT_ID_CONFIG, applicationId + "-" + suffix);
        streamsConfiguration.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
        streamsConfiguration.put(AbstractKafkaSchemaSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, schemaRegistryUrl);
        // Specify default (de)serializers for record keys and for record values.
        streamsConfiguration.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
        streamsConfiguration.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName();
        streamsConfiguration.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
        streamsConfiguration.put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, 10 * 1000);
}

But my values consist of type string, double and long - not just string. How can I configure the properties to read for all types? Currently, in the messages being produced I can see all the values pushed together as one string value rather than each having their own field.

dtolnay
  • 9,621
  • 5
  • 41
  • 62
st123
  • 246
  • 3
  • 14

1 Answers1

0

You'd need to look at your producer code to see what formats are really sent. StringSerializer will always toString the data sent, and you can expect Serdes.String() to do something similar (if it consumes data from IntSerializer, then they will be strings instead)

If you really want to mix types, use JSON/Avro/Protobuf serializers/deserializers in all components in your codes

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245