Skip to content

Commit

Permalink
chore: Fix Avro and Protobuf serialization/deserialization Kamelets
Browse files Browse the repository at this point in the history
Use schema resolvers from Camel core
  • Loading branch information
christophd committed May 3, 2024
1 parent 673ed81 commit f11d27c
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 258 deletions.
5 changes: 2 additions & 3 deletions avro-deserialize-action.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ spec:
x-descriptors:
- 'urn:alm:descriptor:com.tectonic.ui:checkbox'
dependencies:
- "mvn:org.apache.camel.kamelets:camel-kamelets-utils:2.3.0"
- "camel:kamelet"
- "camel:core"
- "camel:jackson-avro"
template:
beans:
- name: schemaResolver
type: "#class:org.apache.camel.kamelets.utils.format.converter.avro.AvroSchemaResolver"
type: "#class:org.apache.camel.component.jackson.avro.transform.AvroSchemaResolver"
property:
- key: validate
value: '{{validate}}'
Expand All @@ -51,5 +50,5 @@ spec:
library: Jackson
unmarshalType: com.fasterxml.jackson.databind.JsonNode
schemaResolver: "#bean:{{schemaResolver}}"
- remove-header:
- removeHeader:
name: "Content-Type"
5 changes: 2 additions & 3 deletions avro-serialize-action.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ spec:
x-descriptors:
- 'urn:alm:descriptor:com.tectonic.ui:checkbox'
dependencies:
- "mvn:org.apache.camel.kamelets:camel-kamelets-utils:2.3.0"
- "camel:kamelet"
- "camel:core"
- "camel:jackson-avro"
template:
beans:
- name: schemaResolver
type: "#class:org.apache.camel.kamelets.utils.format.converter.avro.AvroSchemaResolver"
type: "#class:org.apache.camel.component.jackson.avro.transform.AvroSchemaResolver"
property:
- key: validate
value: '{{validate}}'
Expand All @@ -51,6 +50,6 @@ spec:
library: Jackson
unmarshalType: com.fasterxml.jackson.databind.JsonNode
schemaResolver: "#bean:{{schemaResolver}}"
- set-header:
- setHeader:
name: "Content-Type"
constant: "application/avro"
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ spec:
x-descriptors:
- 'urn:alm:descriptor:com.tectonic.ui:checkbox'
dependencies:
- "mvn:org.apache.camel.kamelets:camel-kamelets-utils:2.3.0"
- "camel:kamelet"
- "camel:core"
- "camel:jackson-avro"
template:
beans:
- name: schemaResolver
type: "#class:org.apache.camel.kamelets.utils.format.converter.avro.AvroSchemaResolver"
type: "#class:org.apache.camel.component.jackson.avro.transform.AvroSchemaResolver"
property:
- key: validate
value: '{{validate}}'
Expand All @@ -51,5 +50,5 @@ spec:
library: Jackson
unmarshalType: com.fasterxml.jackson.databind.JsonNode
schemaResolver: "#bean:{{schemaResolver}}"
- remove-header:
- removeHeader:
name: "Content-Type"
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ spec:
x-descriptors:
- 'urn:alm:descriptor:com.tectonic.ui:checkbox'
dependencies:
- "mvn:org.apache.camel.kamelets:camel-kamelets-utils:2.3.0"
- "camel:kamelet"
- "camel:core"
- "camel:jackson-avro"
template:
beans:
- name: schemaResolver
type: "#class:org.apache.camel.kamelets.utils.format.converter.avro.AvroSchemaResolver"
type: "#class:org.apache.camel.component.jackson.avro.transform.AvroSchemaResolver"
property:
- key: validate
value: '{{validate}}'
Expand All @@ -51,6 +50,6 @@ spec:
library: Jackson
unmarshalType: com.fasterxml.jackson.databind.JsonNode
schemaResolver: "#bean:{{schemaResolver}}"
- set-header:
- setHeader:
name: "Content-Type"
constant: "application/avro"
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
template:
beans:
- name: schemaResolver
type: "#class:org.apache.camel.kamelets.utils.format.converter.protobuf.ProtobufSchemaResolver"
type: "#class:org.apache.camel.component.jackson.protobuf.transform.ProtobufSchemaResolver"
property:
- key: schema
value: '{{schema:}}'
Expand All @@ -42,5 +42,5 @@ spec:
library: Jackson
unmarshalType: com.fasterxml.jackson.databind.JsonNode
schemaResolver: "#bean:{{schemaResolver}}"
- remove-header:
- removeHeader:
name: "Content-Type"
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
template:
beans:
- name: schemaResolver
type: "#class:org.apache.camel.kamelets.utils.format.converter.protobuf.ProtobufSchemaResolver"
type: "#class:org.apache.camel.component.jackson.protobuf.transform.ProtobufSchemaResolver"
property:
- key: schema
value: '{{schema:}}'
Expand All @@ -42,6 +42,6 @@ spec:
library: Jackson
unmarshalType: com.fasterxml.jackson.databind.JsonNode
schemaResolver: "#bean:{{schemaResolver}}"
- set-header:
- setHeader:
name: "Content-Type"
constant: "application/protobuf"
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
public enum MimeType {
JSON("application/json"),
PROTOBUF("application/protobuf"),
PROTOBUF_BINARY("protobuf/binary"),
PROTOBUF_STRUCT("protobuf/x-struct"),
AVRO("application/avro"),
AVRO_BINARY("avro/binary"),
AVRO_STRUCT("avro/x-struct"),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.jackson.avro.transform.AvroSchemaResolver;
import org.apache.camel.component.jackson.protobuf.transform.ProtobufSchemaResolver;
import org.apache.camel.component.jackson.transform.JsonSchemaResolver;
import org.apache.camel.kamelets.utils.format.MimeType;
import org.apache.camel.kamelets.utils.format.schema.protobuf.ProtobufSchemaResolver;
import org.apache.camel.util.ObjectHelper;

/**
Expand Down Expand Up @@ -63,6 +63,8 @@ public void process(Exchange exchange) throws Exception {
private Processor fromMimeType(MimeType mimeType) {
switch (mimeType) {
case PROTOBUF:
case PROTOBUF_BINARY:
case PROTOBUF_STRUCT:
ProtobufSchemaResolver protobufSchemaResolver = new ProtobufSchemaResolver();
protobufSchemaResolver.setSchema(this.schema);
protobufSchemaResolver.setContentClass(this.contentClass);
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit f11d27c

Please sign in to comment.