I am trying to create a generic receiver for Avro messages in Spring Cloud Data Flow but I am running into some bother. The setup I have currently is a processor converting my input data into an Avro message and pushing this out to the sink. I am using the Spring Schema Registry server and I can see the the schema being POSTed to it and successfully being stored, I can also see it being successfully being retrieved from the registry server by my sink.
If I place my Avro generated object from the processor into the sink application and configure my sink like so with the type declared it works perfectly.
@StreamListener(Sink.INPUT)
public void logHandler(DataRecord data) {
LOGGER.info("data='{}'", data.toString());
}
However, I would like to make it so that my sink does not need to be aware of the schema ahead of time e.g. use the schema from the schema registry and access the fields through data.get("fieldName")
I was hoping to accomplish this through use of the Avro GenericRecord like so:
@StreamListener(Sink.INPUT)
public void logHandler(GenericRecord data) {
LOGGER.info("data='{}'", data.toString());
}
But this throws an exception into the logs:
2017-12-05 12:10:15,206 DEBUG -L-2 o.s.w.c.RestTemplate:691 - GET request for "http://192.168.99.100:8990/datarecord/avro/v1" resulted in 200 (null)
org.springframework.messaging.converter.MessageConversionException: No schema can be inferred from type org.apache.avro.generic.GenericRecord and no schema has been explicitly configured.
Is there a way to accomplish what I am trying to do?