- Newest
- Most votes
- Most comments
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)
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:
-
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.
-
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.
-
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)
-
If you're using auto-registration, make sure it's enabled and that you have the necessary permissions.
-
Try explicitly specifying the schema definition rather than relying on the serializer to infer it from your GenericRecord.
-
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.