Azure Eventhubs Sink
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Sends each message as an event to an event hub in Azure Event Hubs, the Azure service for event streams.
Use it to publish events, such as clicks, sensor readings or changes, for stream processing or for other applications to read. To receive them, use azure-eventhubs-source.
Input: the body becomes the body of the event: text, bytes or a stream. A Map fails: turn it into JSON text first, for example with json-serialize-action. A List is sent as one event per element. The optional partition-id header (or ce-partition-id) is the partition to send to, such as 0; without it, and without partitionKey, Event Hubs chooses one.
Output: the message is unchanged.
Good to know: log in with sharedAccessName and sharedAccessKey, with connectionString, or with credentialType AZURE_IDENTITY. Set namespaceName and eventhubName unless connectionString is set. The shared access policy needs the Send right. Headers that start with CamelAzureEventHubs are removed from the message first, so they cannot change what the Kamelet does. With partitionKey set, a message with a partition-id or ce-partition-id header fails.
Configuration Options
The following table summarizes the configuration options available for the azure-eventhubs-sink Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Connection String | A connection string of a shared access policy, such as | string | |||
Credential Type | How to log in to Event Hubs. Enum values: * CONNECTION_STRING * AZURE_IDENTITY | string | CONNECTION_STRING | ||
Event Hub Name | The name of the event hub in the namespace to send the events to. Required unless | string | orders | ||
Event Hubs Namespace | The name of the Event Hubs namespace, the first part of its address | string | my-namespace | ||
Partition Key | A partition key for all the events, such as | string | orders | ||
Shared Access Key | The primary or secondary key of the shared access policy named in | string | |||
Shared Access Name | The name of a shared access policy of the namespace or of the event hub, such as | string | RootManageSharedAccessKey |
Dependencies
At runtime, the azure-eventhubs-sink Kamelet relies upon the presence of the following dependencies:
-
camel:azure-eventhubs
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing 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:azure-eventhubs-sink" You can now run it directly through the following command
camel run route.yaml Azure Event Hubs Sink Kamelet Description
Authentication methods
In this Kamelet, you can use these Azure authentication methods:
-
Azure Identity mechanism:
AZURE_IDENTITY -
Connection string:
CONNECTION_STRING
The order of evaluation for AZURE_IDENTITY is the following:
-
Enviroment
-
Workload Identity
-
Managed Identity
-
Azure Developer CLI
-
IntelliJ
-
Azure CLI
-
Azure Powershell
For more information, see the Azure Identity documentation
Optional Headers
In the headers, you can optionally set the partition-id / ce-partition-id property to specify the partition id for a specific item.
If you set neither the header nor partitionKey, Azure Event Hubs chooses the partition.
Sending all events to the same partition
Event Hubs keeps the order of the events only within a partition. To read the events in the order they were sent, set partitionKey: Event Hubs sends all the events with the same partition key to the same partition, which it chooses from the key. Do not set the partition-id header as well: a message with both fails with the error Both partitionKey and partitionId are set.
Connecting with a connection string
Instead of namespaceName, eventhubName, sharedAccessName and sharedAccessKey, you can set connectionString. It must end with ;EntityPath= and the name of the event hub, which the connection string of a policy of the namespace does not have: add it.
- route:
from:
uri: "kamelet:kafka-source"
parameters:
topic: "orders"
bootstrapServers: "kafka.example.com:9092"
saslAuthType: "NONE"
steps:
- to:
uri: "kamelet:azure-eventhubs-sink"
parameters:
connectionString: "Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=send-policy;SharedAccessKey=...;EntityPath=orders"
partitionKey: "orders" The connection string holds the key, so keep it in a secret, like sharedAccessKey.