davsclaus opened a new pull request, #3327: URL: https://github.com/apache/camel-kamelets/pull/3327
Fixes #3326. A new action Kamelet, `protobuf-message-action`, that turns JSON text into a Protobuf message (a `DynamicMessage`) of the `.proto` schema you give, with no classes generated by `protoc`. It is meant for `kafka-sink` with `schemaRegistryVendor` and `schemaFormat: protobuf`, which needs a Protobuf message object and fails on JSON text. Until now, a YAML user had to build the message in code. It uses the `schema` and `messageName` options of the protobuf data format from [CAMEL-27329](https://issues.apache.org/jira/browse/CAMEL-27329) (apache/camel#30550). ## The Kamelet - `schema` (required): the `.proto` text, or where to read it: `classpath:`, `file:` or an `http:` URL, such as `/subjects/<subject>/versions/latest/schema` of a Confluent API registry. - `messageName` (optional): `Order`, `shop.Order` or the nested `Order.Line`. By default it is the first message type of the schema. - Input: JSON text or its bytes, in the Protobuf JSON mapping. Output: a `com.google.protobuf.DynamicMessage`, with the headers kept. - Dependencies: `camel:protobuf` and `camel:protobuf-schema`. The `.proto` parser brings Kotlin and Guava (about 6 MB), so only users of this action get it. `kafka-sink` does not change, apart from its description, which now points to the action. Each fact in the description was checked by running the Kamelet: - A field can be given by its schema name or in lowerCamelCase, a 64-bit number as text, an enum by its name, and `google/protobuf/timestamp.proto` in its JSON form. - A JSON field that the schema does not have is dropped. - A value of the wrong type fails the message with `InvalidProtocolBufferException`. - An unknown `messageName`, a syntax error or another import fails at startup. ## Tests - New `protobuf/protobuf-message-action.citrus.it.yaml` (ProtobufIT), covering: - The JSON mapping above, with a nested message type read from `byte[]`. - The wrong-type error. - The startup failure for an unknown `messageName`. - `kafka-schema-registry-protobuf-route.yaml` and `kafka-batch-schema-registry-protobuf-route.yaml` now use the new action instead of the Groovy step, so the Confluent (Redpanda), Apicurio and batch protobuf tests run through it. - Local runs on the 4.24.0-SNAPSHOT: ProtobufIT 3/3, KafkaIT 14/14, and `./mvnw clean install -DskipITs` passes. A #3190 upgrade note follows after the merge. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
