You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/03/31 12:16:27 UTC

[camel-kamelets] 01/05: Create a Kamelet action for setting a specific kafka key based on a particular header incoming

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch c-kamelets-1430
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git

commit f61c2b8ed880ab10eaca6c6c0fa13adceb1eb006
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Mar 31 14:09:53 2023 +0200

    Create a Kamelet action for setting a specific kafka key based on a particular header incoming
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 kamelets/set-kafka-key-action.kamelet.yaml | 68 ++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/kamelets/set-kafka-key-action.kamelet.yaml b/kamelets/set-kafka-key-action.kamelet.yaml
new file mode 100644
index 00000000..b2d9c68e
--- /dev/null
+++ b/kamelets/set-kafka-key-action.kamelet.yaml
@@ -0,0 +1,68 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: set-kafka-key-action
+  labels:
+    camel.apache.org/kamelet.type: "action"
+  annotations:
+    camel.apache.org/kamelet.support.level: "Stable"
+    camel.apache.org/catalog.version: "4.0.0-SNAPSHOT"
+    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Actions"
+    camel.apache.org/kamelet.namespace: "Kafka"
+spec:
+  definition:
+    title: "Set Kafka Key Action"
+    description: |-
+      Set Kafka Key based on a specific incoming header value from the message body.
+
+      The headerName parameter allows you to specify which header value to set as Kafka Key.
+    required:
+      - field
+    properties:
+      headerName:
+        title: Field
+        description: The name of the header to set as Kafka Key
+        type: string
+      forceHeaderDeletion:
+        title: Force Header Deletion
+        description: If true, it will remove the header with name headerName from the Exchange after setting it as Kafka Key
+        type: boolean
+        x-descriptors:
+          - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
+        default: false
+    type: object
+  dependencies:
+  - "camel:kamelet"
+  - "camel:core"
+  template:
+    from:
+      uri: kamelet:source
+      steps:
+      - set-header:
+          name: kafka.KEY
+          simple: "${header.{{headerName}}}"
+      - choice:
+          precondition: true
+          when:
+            - simple: '${properties:forceHeaderDeletion:true}'
+              steps:
+              - remove-header:
+                  name: "{{headerName}}"