Chapter 32. Insert Header Action
Adds an header with a simple language parsed expression to the message in transit.
32.1. Configuration Options Copy linkLink copied to clipboard!
The following table summarizes the configuration options available for the insert-header-action Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
| name * | Name | The name of the header to be added. For Knative only, the name of the header requires a CloudEvent (ce-) prefix. | string | headername | |
| value * | Value | The value of the header to be added | string |
* = Fields marked with an asterisk are mandatory.
32.2. Dependencies Copy linkLink copied to clipboard!
32.2.1. Quarkus dependencies Copy linkLink copied to clipboard!
<dependencies>
<dependency>
<groupId>org.apache.camel.kamelets</groupId>
<artifactId>camel-kamelets-utils</artifactId>
<version>4.8.5</version>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-insert-header-action</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-kamelet</artifactId>
</dependency>
</dependencies>
32.3. Usage Copy linkLink copied to clipboard!
32.3.1. Camel JBang usage Copy linkLink copied to clipboard!
32.3.1.1. Prerequisites for JBang Copy linkLink copied to clipboard!
- Install JBang.
You have executed the following command:
jbang app install camel@apache/camel
32.3.1.2. Running a route with JBang Copy linkLink copied to clipboard!
Suppose you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:log-sink"
You can now run it directly through the following command.
camel run route.yaml
32.3.2. Knative Action Copy linkLink copied to clipboard!
You must use the insert-header-action Kamelet as an intermediate step in a Knative binding.
insert-header-action-binding.yaml
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: insert-header-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: insert-header-action
properties:
name: "The Name"
value: "The Value"
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
32.3.3. Kafka Action Copy linkLink copied to clipboard!
You must use the insert-header-action Kamelet as an intermediate step in a Kafka binding.
insert-header-action-binding.yaml
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: insert-header-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: insert-header-action
properties:
name: "The Name"
value: "The Value"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic