| # --------------------------------------------------------------------------- |
| # 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: error-handler |
| spec: |
| definition: |
| title: "DLC and Log" |
| description: "Push an event to a kafka topic and log an error message" |
| required: |
| - kafka-brokers |
| - kafka-topic |
| - kafka-service-account-id |
| - kafka-service-account-secret |
| - log-message |
| properties: |
| kafka-brokers: |
| title: Kafka Brokers |
| description: the bootstrap server |
| type: string |
| example: "xyz-ins--rplssqfz-yyyyyyy-crojg.bf2.kafka.my-clud-service.com:443" |
| kafka-topic: |
| title: Kafka Topic |
| description: the DLC topic |
| type: string |
| example: "my-dlc" |
| kafka-service-account-id: |
| title: Service Account ID |
| description: the SA to use |
| type: string |
| example: "srvc-acct-xxxxxx-519b-453f-9f68-yyyyyyyyy" |
| kafka-service-account-secret: |
| title: Service Account Secret |
| description: the SA secrete to use |
| type: string |
| example: "xxxxxxxxx-46c7-4c6c-a753-yyyyyyyyyyyyyyy" |
| log-message: |
| title: Message |
| description: A message warning to log |
| type: string |
| example: "error while checking the source" |
| template: |
| from: |
| uri: kamelet:source |
| steps: |
| # First step: send to the DLC (dead letter channel) for future processing |
| - to: |
| uri: kafka:{{kafka-topic}} |
| parameters: |
| brokers: "{{kafka-brokers}}" |
| security-protocol: SASL_SSL |
| sasl-mechanism: PLAIN |
| sasl-jaas-config: "org.apache.kafka.common.security.plain.PlainLoginModule required username='{{kafka-service-account-id}}' password='{{kafka-service-account-secret}}';" |
| # Log an error message to notify about the failure |
| - set-body: |
| constant: "{{log-message}} - worry not, the event is stored in the DLC" |
| - to: "log:error-sink" |