Skip to content

Commit

Permalink
Use Data Type Transformer API provided by Camel 4.0
Browse files Browse the repository at this point in the history
- Camel 4.0 introduces a data type support based on the transformer API. Use this instead of the interim implementation in utils
- Remove data type transformers that are now provided by Camel core
- Remove interim data type processor implementation in this repository and use data type processor implementation provided by Camel 4
- Refactor data type action Kamelet to use new Camel 4 data type processor
- Keep those data type transformer implementations (Avro, Json Struct, ...) that have not been ported to Camel core yet
- Update to YAKS 0.16.0 as it allows to explicitly set the camel-kamelets version in Camel JBang
- Update aws-ddb-sink Kamelet to use new data type transform API
  • Loading branch information
christophd committed Aug 31, 2023
1 parent 5916e97 commit 6980202
Show file tree
Hide file tree
Showing 49 changed files with 191 additions and 1,881 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/yaks-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ concurrency:
cancel-in-progress: true

env:
YAKS_VERSION: 0.15.1
YAKS_RUN_OPTIONS: "--timeout=15m --local -e YAKS_CAMELK_MAX_ATTEMPTS=10 -e YAKS_JBANG_CAMEL_VERSION=4.0.0 -e YAKS_JBANG_KAMELETS_LOCAL_DIR=../../../kamelets -e YAKS_CAMELK_KAMELET_API_VERSION=v1alpha1"
YAKS_VERSION: 0.16.0
YAKS_RUN_OPTIONS: "--timeout=15m --local -e YAKS_CAMELK_MAX_ATTEMPTS=10 -e YAKS_JBANG_CAMEL_VERSION=4.0.0 -e YAKS_JBANG_KAMELETS_VERSION=4.0.0-SNAPSHOT -e YAKS_JBANG_KAMELETS_LOCAL_DIR=../../../kamelets -e YAKS_CAMELK_KAMELET_API_VERSION=v1alpha1"

jobs:
test:
Expand Down Expand Up @@ -88,9 +88,6 @@ jobs:
echo "Running YAKS tests for Kamelets"
yaks run test/aws-ddb-sink $YAKS_RUN_OPTIONS
yaks run test/aws-s3 $YAKS_RUN_OPTIONS
yaks run test/avro-data-type $YAKS_RUN_OPTIONS
yaks run test/avro-serdes-action $YAKS_RUN_OPTIONS
Expand All @@ -104,8 +101,11 @@ jobs:
yaks run test/earthquake-source $YAKS_RUN_OPTIONS
yaks run test/rest-openapi-sink $YAKS_RUN_OPTIONS
yaks run test/kafka $YAKS_RUN_OPTIONS
yaks run test/aws-s3 $YAKS_RUN_OPTIONS
yaks run test/aws-ddb-sink $YAKS_RUN_OPTIONS
- uses: actions/upload-artifact@v3
if: failure()
with:
name: dumps
path: test/**/.yaks-jbang/*-output.txt
path: test/**/.yaks-jbang
13 changes: 2 additions & 11 deletions kamelets/aws-ddb-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,14 @@ spec:
- "camel:aws2-ddb"
- "camel:kamelet"
template:
beans:
- name: dataTypeRegistry
type: "#class:org.apache.camel.kamelets.utils.format.DefaultDataTypeRegistry"
- name: dataTypeProcessor
type: "#class:org.apache.camel.kamelets.utils.format.DataTypeProcessor"
properties:
scheme: 'aws2-ddb'
format: 'application-json'
registry: '#bean:{{dataTypeRegistry}}'
from:
uri: "kamelet:source"
steps:
- set-property:
name: operation
constant: "{{operation}}"
- process:
ref: "{{dataTypeProcessor}}"
- transform:
to-type: "aws2-ddb:application-json"
- to:
uri: "aws2-ddb:{{table}}"
parameters:
Expand Down
27 changes: 16 additions & 11 deletions kamelets/data-type-action.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,33 @@ spec:
title: Component Scheme
description: The data type component scheme enables users to apply Camel component specific data type conversions.
type: string
default: "camel"
example: "camel"
format:
title: Data Type Format
description: Defines the data type that will be applied by this action. The Kamelet catalog supports different data types and performs automatic message conversion according to the given type.
description: Defines the data type that will be applied by this action. Apache Camel and the Kamelet catalog support different data types and performs automatic message conversion according to the given type.
type: string
dependencies:
- "mvn:org.apache.camel.kamelets:camel-kamelets-utils:4.0.0-SNAPSHOT"
- "camel:kamelet"
- "camel:core"
template:
beans:
- name: dataTypeRegistry
type: "#class:org.apache.camel.kamelets.utils.format.DefaultDataTypeRegistry"
- name: dataTypeProcessor
type: "#class:org.apache.camel.kamelets.utils.format.DataTypeProcessor"
properties:
scheme: '{{scheme}}'
format: '{{format}}'
registry: '#bean:{{dataTypeRegistry}}'
type: "#class:org.apache.camel.processor.transformer.DataTypeProcessor"
from:
uri: "kamelet:source"
steps:
- process:
- choice:
when:
- simple: "'{{?scheme}}' != ''"
steps:
- set-property:
name: CamelDataType
simple: "{{?scheme}}:{{format}}"
otherwise:
steps:
- set-property:
name: CamelDataType
simple: "{{format}}"
- bean:
ref: "{{dataTypeProcessor}}"
method: process

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6980202

Please sign in to comment.