Skip to content

Trouble retrieving Glue Schema from Registry

0

I have an application running on Camel 4.4.2. This project is an upgrade from a prior version (on Camel 3.4.4) which used to work but now fails pulling a Glue Schema from the Registry. I'm suspecting a jar version mismatch with some jars we had to update because of the camel upgrade.

The application reads from and writes to various Apache Kafka topics. It uses AWS IAM Role Authentication. The authentication works fine. Consuming from the topics works fine using schema-registry-serde-1.1.25, avro-1.10.4 (or avro-1.11.2), kafka-clients-3.9.1 (or 3.0.1). But our producer fails to find the schema in the glue registry.

DEBUG 41 --- [ClientTCPWorker] o.a.camel.component.kafka.KafkaProducer  : Sending message to topic: wire-disposition-qa1, partition: null, key: null
 INFO 41 --- [ad | producer-3] org.apache.kafka.clients.Metadata        : [Producer clientId=producer-3] Resetting the last seen epoch of partition wire-disposition-qa1-0 to 121 since the associated topicId changed from null to GkJ1xwdJSmeWUjWOJCCKUQ
 INFO 41 --- [ad | producer-3] org.apache.kafka.clients.Metadata        : [Producer clientId=producer-3] Resetting the last seen epoch of partition wire-disposition-qa1-2 to 120 since the associated topicId changed from null to GkJ1xwdJSmeWUjWOJCCKUQ
 INFO 41 --- [ad | producer-3] org.apache.kafka.clients.Metadata        : [Producer clientId=producer-3] Resetting the last seen epoch of partition wire-disposition-qa1-1 to 120 since the associated topicId changed from null to GkJ1xwdJSmeWUjWOJCCKUQ
DEBUG 41 --- [ClientTCPWorker] .s.s.s.GlueSchemaRegistryKafkaSerializer : **Schema Version Id is null. Trying to register the schema.**
DEBUG 41 --- [ClientTCPWorker] .s.s.GlueSchemaRegistrySerializerFactory : **Returning Avro serializer instance from GlueSchemaRegistrySerializerFactory**
ERROR 41 --- [ClientTCPWorker] c.a.s.schemaregistry.utils.AVROUtils     : **Unsupported Avro Data Formats**
ERROR 41 --- [ClientTCPWorker] c.a.s.schemaregistry.utils.AVROUtils     : **Unsupported Type of Record received**
com.amazonaws.services.schemaregistry.exception.AWSSchemaRegistryException: Unsupported Type of Record received
at com.amazonaws.services.schemaregistry.utils.AVROUtils.getSchemaDefinition(AVROUtils.java:55) ~[fact-1.0-SNAPSHOT-all.jar:na]
at com.amazonaws.services.schemaregistry.serializers.avro.AvroSerializer.getSchemaDefinition(AvroSerializer.java:141) ~[fact-1.0-SNAPSHOT-all.jar:na]
at com.amazonaws.services.schemaregistry.serializers.GlueSchemaRegistrySerializationFacade.getSchemaDefinition(GlueSchemaRegistrySerializationFacade.java:140) ~[fact-1.0-SNAPSHOT-all.jar:na]
at com.amazonaws.services.schemaregistry.serializers.GlueSchemaRegistryKafkaSerializer.prepareInput(GlueSchemaRegistryKafkaSerializer.java:157) ~[fact-1.0-SNAPSHOT-all.jar:na]
at com.amazonaws.services.schemaregistry.serializers.GlueSchemaRegistryKafkaSerializer.serialize(GlueSchemaRegistryKafkaSerializer.java:113) ~[fact-1.0-SNAPSHOT-all.jar:na]
at org.apache.kafka.common.serialization.Serializer.serialize(Serializer.java:62) ~[kafka-clients-3.0.1.jar!/:na]
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:901) ~[kafka-clients-3.0.1.jar!/:na]
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:861) ~[kafka-clients-3.0.1.jar!/:na]
at org.apache.camel.component.kafka.KafkaProducer.doSend(KafkaProducer.java:521) ~[camel-kafka-4.4.2.jar!/:4.4.2]
at org.apache.camel.component.kafka.KafkaProducer.process(KafkaProducer.java:479) ~[camel-kafka-4.4.2.jar!/:4.4.2]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:210) ~[camel-core-processor-4.4.2.jar!/:4.4.2]
Caused by org.apache.camel.RuntimeCamelException: com.amazonaws.services.schemaregistry.exception.AWSSchemaRegistryException: Unsupported Type of Record received
at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:51) ~[camel-api-4.4.2.jar!/:4.4.2]

The code I have that produces the message hasn't changed since the version where it worked. All fields in the message are either String, Int, Long, or a nested GenericRecord. I have confirmed that the schema exists in AWS Glue repository. I have GetSchema permission. The old version of my product can pull it. The point of failure in my code is where I try to route the GenericRecord to the kafkaTopic:

from("direct:TxnRequestFulcrumResponse").routeId("TxnRequestWireResponse")
                .bean(TxnReqTransformation.class,
                        "createWireResponse(${header.TxnRequestWireResponseHeader}, ${header.TxnRequestWireResponseCorrelationId},"
                                + "${header.TxnRequestWireResponseRtnCode}, ${header.TxnRequestWireResponseActionCode})")
                .log("Wire Response: ${body}")
                **.to(kafkaTxnResponseUri)**

The kafkaTxnResponseUri is a fully qualified URI for our Kafka Topic. The bean createWireResponse returns a GenericRecord.

public GenericRecord createWireResponse(Header header, String correlationId,
                                               String rrrSysRtnCode, String rrrSysRtnAction) throws IOException {
...

I'm trying not to make this too long. I'm suspecting a jar version conflict just because there are so many moving parts and because it used to work. We know the data is right. We know we can authenticate, We can validate against a text export of the schema. We just can't pull the schema from the registry. Appreciate any and all help. Thanks.

2 Answers
0
Accepted Answer

I thought I would provide what solved this problem for us. Forgive me if I get some details wrong along the way -- it still confuses me and I'm not sure I have the explanation 100% right but here goes.

We have a KafkaConfig class that defines our KafkaComponent objects and their KafkaConfigurations. These are all fully specified to the best of my knowledge using things like...

kafkaConfiguration.setSecurityProtocol("SASL_SSL");
kafkaConfiguration.setSaslMechanism("AWS_MSK_IAM");

That had been working for us just fine on our prior version of Camel and Spring. When we upgraded, though, we found that our Kafka Consumers were failing to use these properties and were falling back on defaults (plaintext...). I spent hours looking at this. If I Autowired my KafkaConfig (from Spring) the object and its configurations looked fine. But if I retrieved it from the Camel Context, it looked like it was using defaults (printing the objects system hash id showed they were the SAME object). Could never understand this and ended up working around it but fully qualifying our kafka URIs in the routes. Eventually figured out if we changed our KafkaConfig class to set things like:

additional.put("security.protocol", "SASL_SSL");
additional.put("sasl.mechanism", "AWS_MSK_IAM");

our routes started working. Never considered Spring might have a problem with this. Turns out somewhere in Camel 3.5.x, settings were introduced to AutoConfigure Spring components that aren't fully configured. Stepping through in a debugger showed that the serializer was trying to pull a String serializer rather than the Avro Serializer that was on KafkaConfig. We could avoid this by setting

spring.autoconfigure.exclude=org.apache.camel.component.kafka.springboot.KafkaComponentAutoConfiguration

But we also went for redundant settings in our KafkaConfig like:

additional.put("security.protocol", "SASL_SSL");
additional.put("sasl.mechanism", "AWS_MSK_IAM");
kafkaConfiguration.setSecurityProtocol("SASL_SSL");
kafkaConfiguration.setSaslMechanism("AWS_MSK_IAM");
additional.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,StringSerializer.class.getName());
additional.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,GlueSchemaRegistryKafkaSerializer.class.getName());
kafkaConfiguration.setKeySerializer("org.apache.kafka.common.serialization.StringSerializer");
kafkaConfiguration.setValueSerializer("com.amazonaws.services.schemaregistry.serializers.GlueSchemaRegistryKafkaSerializer");

It's incredibly weird to me that this is necessary and still makes me think I must be doing something wrong for Spring and CamelContext to conflict each other. But I'm going to accept that I don't understand. This solves my problem. Posting it here for any other poor soul who finds themselves in this position.

our working versions: schema-registry-serde-1.1.25 avro-1.10.2 other awssdk classes 2.31.54 glue jar was pulled in by schema-registry-serde kafka-clients version didn't make a difference (3.0.1, 3.9.1 or confluent version 6.2.8)

answered a year ago

EXPERT

reviewed a year ago

0

Based on your description, it appears you're experiencing an issue with the AWS Glue Schema Registry serialization process after upgrading to Camel 4.4.2. The error "Unsupported Type of Record received" suggests that the serializer is unable to properly handle the GenericRecord you're trying to send.

This is likely due to a compatibility issue between your AWS Glue Schema Registry SerDe library version and the Avro version you're using. The error occurs during the schema registration process when the serializer tries to determine the schema definition from your record.

Here are some potential solutions:

  1. Check that you're using compatible versions of the AWS Glue Schema Registry SerDe library and Avro. The schema-registry-serde-1.1.25 should work with avro-1.10.4, but there might be conflicts with other dependencies introduced by Camel 4.4.2.

  2. Verify that your GenericRecord implementation is compatible with the serializer's expectations. The error suggests that the serializer doesn't recognize the type of record you're providing.

  3. Ensure you've properly configured the AWS Glue Schema Registry properties in your producer configuration. Important properties include:

  • SCHEMA_AUTO_REGISTRATION_SETTING
  • SCHEMA_NAME
  • REGISTRY_NAME
  • DATA_FORMAT (should be set to AVRO)
  1. If you're using auto-registration, make sure it's enabled and that you have the necessary permissions.

  2. Try explicitly specifying the schema definition rather than relying on the serializer to infer it from your GenericRecord.

  3. Check if there are any changes in how Camel 4.4.2 handles GenericRecord objects compared to your previous version.

Since the consumer works fine but the producer fails, focusing on the serialization process and how the GenericRecord is created and passed to the Kafka producer would be the most productive approach.
Sources
GetSchemaByDefinition - AWS Glue
Schema registry - AWS Glue
Installing SerDe Libraries - AWS Glue

answered a year ago

  • Note: we cannot enable auto-registration because another product group owns the schema and we are not able to change it.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.