Chapter 28. Has Header Filter Action
Filter message based on the presence of one header.
28.1. Configuration Options Copy linkLink copied to clipboard!
The following table summarizes the configuration options available for the has-header-filter-action Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
| name * | Header Name | The header name to evaluate. The header name must be passed by the source Kamelet. For Knative only, the name of the header requires a CloudEvent (ce-) prefix. | string | headerName | |
| value | Header Value | An optional header value to compare the header to | string | headerValue |
* = Fields marked with an asterisk are mandatory.
28.2. Dependencies Copy linkLink copied to clipboard!
28.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-has-header-filter-action</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-kamelet</artifactId>
</dependency>
</dependencies>
28.3. Usage Copy linkLink copied to clipboard!
28.3.1. Camel JBang usage Copy linkLink copied to clipboard!
28.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
28.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
28.3.2. Knative Action Copy linkLink copied to clipboard!
You can use the has-header-filter-action Kamelet as an intermediate step in a Knative binding.
has-header-filter-action-binding.yaml
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: has-header-filter-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: "my-header"
value: "my-value"
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: has-header-filter-action
properties:
name: "my-header"
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
28.3.3. Kafka Action Copy linkLink copied to clipboard!
You can use the has-header-filter-action Kamelet as an intermediate step in a Kafka binding.
has-header-filter-action-binding.yaml
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: has-header-filter-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: "my-header"
value: "my-value"
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: has-header-filter-action
properties:
name: "my-header"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic