This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new 01c188bed chore: the Azure Service Bus Kamelets work with
session-enabled queues, and the source can read a dead-letter queue (#3170)
(#3207)
01c188bed is described below
commit 01c188bed1371ba3f440ebe012015f52b490fd47
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 21:38:06 2026 +0100
chore: the Azure Service Bus Kamelets work with session-enabled queues, and
the source can read a dead-letter queue (#3170) (#3207)
azure-servicebus-source could not read a queue or subscription with
sessions enabled, nor the dead-letter queue, and azure-servicebus-sink
could not send to a queue with sessions, which requires a session ID on
every message. Neither Kamelet could log in with an Azure identity,
because they required a connection string and never set the namespace.
azure-servicebus-source gets sessionEnabled, maxConcurrentSessions and
subQueue (DEAD_LETTER_QUEUE, TRANSFER_DEAD_LETTER_QUEUE), and documents
the session ID and dead-letter reason headers. azure-servicebus-sink gets
sessionId, a fixed value: camel-azure-servicebus does not read a session
ID header. Both get fullyQualifiedNamespace, and connectionString is no
longer required, so that credentialType AZURE_IDENTITY works.
All new options are optional with no default; when they are unset the
endpoint URIs are the same as before. The descriptions say when sessions
are needed, what happens to ordering, and how a failing dead letter is
received again. Tested with the Azure Service Bus emulator.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../azure-servicebus-sink-description.adoc | 30 +++++++++++-
.../azure-servicebus-source-description.adoc | 51 +++++++++++++++++++-
kamelets/azure-servicebus-sink.kamelet.yaml | 25 ++++++++--
kamelets/azure-servicebus-source.kamelet.yaml | 54 +++++++++++++++++++---
.../kamelets/catalog/KameletsCatalogTest.java | 2 +-
.../main/resources/META-INF/kamelets-index.json | 4 +-
.../kamelets/azure-servicebus-sink.kamelet.yaml | 25 ++++++++--
.../kamelets/azure-servicebus-source.kamelet.yaml | 54 +++++++++++++++++++---
8 files changed, 220 insertions(+), 25 deletions(-)
diff --git a/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
b/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
index 3a80b4856..7b3e9e78d 100644
--- a/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
+++ b/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
@@ -22,4 +22,32 @@ For more information, see the
https://learn.microsoft.com/en-us/java/api/overvie
For `TOKEN_CREDENTIAL` type, you'll need to add
`com.azure.core.credential.TokenCredential` instance in the Camel registry.
-`AZURE_IDENTITY` and `TOKEN_CREDENTIAL` also need the fully qualified
namespace of Service Bus, which this Kamelet does not set: configure the
`fullyQualifiedNamespace` option of the Camel `azure-servicebus` component, or
use `CONNECTION_STRING`.
+`AZURE_IDENTITY` and `TOKEN_CREDENTIAL` also need **fullyQualifiedNamespace**,
the host name of the Service Bus namespace, such as
`my-namespace.servicebus.windows.net`. Leave **connectionString** unset with
them.
+
+=== Example with a Session ID
+
+A queue created with sessions enabled accepts only messages with a session ID;
without one, the send fails with
+`The SessionId was not set on a message`. A topic accepts them, but each of
its subscriptions with sessions enabled
+moves them to its dead-letter queue. Set **sessionId** to send every message
with that session ID:
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "timer:tick"
+ parameters:
+ period: 60000
+ steps:
+ - setBody:
+ constant: "order-1"
+ - to:
+ uri: "kamelet:azure-servicebus-sink"
+ parameters:
+ topicOrQueueName: "orders"
+ connectionString: "{{servicebus.connection-string}}"
+ sessionId: "customer-42"
+----
+
+A reader of the queue receives the messages of a session in the order they
were sent. The session ID is fixed for the
+Kamelet; the `CamelAzureServiceBusSessionId` header is not read. To spread
messages over several sessions, use one sink
+for each session ID, for example behind a content-based router.
diff --git
a/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
b/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
index 3088de116..8d4185241 100644
--- a/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
+++ b/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
@@ -22,8 +22,57 @@ For more information, see the
https://learn.microsoft.com/en-us/java/api/overvie
For `TOKEN_CREDENTIAL` type, you'll need to add
`com.azure.core.credential.TokenCredential` instance in the Camel registry.
-`AZURE_IDENTITY` and `TOKEN_CREDENTIAL` also need the fully qualified
namespace of Service Bus, which this Kamelet does not set: configure the
`fullyQualifiedNamespace` option of the Camel `azure-servicebus` component, or
use `CONNECTION_STRING`.
+`AZURE_IDENTITY` and `TOKEN_CREDENTIAL` also need **fullyQualifiedNamespace**,
the host name of the Service Bus namespace, such as
`my-namespace.servicebus.windows.net`. Leave **connectionString** unset with
them.
=== Topic vs Queue
The subscribtion name parameter needs to be populated in case of consuming
from a Topic, while it's not required in case of Queue.
+
+=== Example with Sessions
+
+A queue or subscription created with sessions enabled can be read only with
**sessionEnabled** set to `true`. Without
+it, the integration receives nothing and logs a warning every few seconds: `It
is not possible for an entity that
+requires sessions to create a non-sessionful message receiver`. A queue
without sessions cannot be read with it.
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "kamelet:azure-servicebus-source"
+ parameters:
+ topicOrQueueName: "orders"
+ connectionString: "{{servicebus.connection-string}}"
+ sessionEnabled: true
+ maxConcurrentSessions: 8
+ steps:
+ - log: "Order $\{body} of session
$\{header.CamelAzureServiceBusSessionId}"
+----
+
+The messages of one session are received in the order they were sent, and the
next one only once the previous one
+has been processed (unless a step of the integration works asynchronously,
such as a delay). A message whose
+processing fails is received again before the next one of its session.
Different sessions are read at the same time,
+up to **maxConcurrentSessions**, 1 by default, and have no order between them.
A session is kept until it has had no
+message for a minute: with the default of 1, the messages of another session
wait meanwhile.
+
+=== Example Reading the Dead-Letter Queue
+
+Service Bus moves a message to the dead-letter queue of its queue or
subscription, for example once its processing
+has failed the maximum delivery count of times. Set **subQueue** to
`DEAD_LETTER_QUEUE` to read them:
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "kamelet:azure-servicebus-source"
+ parameters:
+ topicOrQueueName: "orders"
+ connectionString: "{{servicebus.connection-string}}"
+ subQueue: "DEAD_LETTER_QUEUE"
+ steps:
+ - log: "Dead letter $\{body}:
$\{header.CamelAzureServiceBusDeadLetterReason} -
$\{header.CamelAzureServiceBusDeadLetterErrorDescription}"
+----
+
+The dead-letter queue has no sessions, so leave **sessionEnabled** unset, even
for a queue with sessions. A
+dead-lettered message whose processing fails stays where it is: it is received
again straight away, over and over,
+and holds up the dead letters behind it. `TRANSFER_DEAD_LETTER_QUEUE` reads
the messages that could not be forwarded
+or transferred instead.
diff --git a/kamelets/azure-servicebus-sink.kamelet.yaml
b/kamelets/azure-servicebus-sink.kamelet.yaml
index d17b59c72..6384e3054 100644
--- a/kamelets/azure-servicebus-sink.kamelet.yaml
+++ b/kamelets/azure-servicebus-sink.kamelet.yaml
@@ -41,9 +41,12 @@ spec:
Output: the message is unchanged.
Good to know: the shared access policy of the connection string needs
the Send right.
+
+ A queue created with sessions enabled accepts only messages with a
session ID: without one, the send fails. A topic accepts them, but each of its
subscriptions with sessions enabled moves them to its dead-letter queue. Set
`sessionId` to send every message with that session ID; a reader of the queue
or subscription then receives the messages of the session in the order they
were sent. The session ID is fixed for the Kamelet: the
`CamelAzureServiceBusSessionId` header is not read, s [...]
+
+ To log in with an Azure identity instead of a connection string, set
`credentialType` to `AZURE_IDENTITY` and `fullyQualifiedNamespace`, and leave
`connectionString` unset.
required:
- topicOrQueueName
- - connectionString
type: object
properties:
topicOrQueueName:
@@ -53,7 +56,7 @@ spec:
example: orders
connectionString:
title: Connection String
- description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`."
+ description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`. Required
with the default `credentialType`, `CONNECTION_STRING`."
type: string
format: password
x-descriptors:
@@ -66,10 +69,22 @@ spec:
enum: ["queue", "topic"]
credentialType:
title: Credential Type
- description: How to log in to Service Bus. Keep `CONNECTION_STRING`,
the default, which uses `connectionString`. `AZURE_IDENTITY` and
`TOKEN_CREDENTIAL` also need the `fullyQualifiedNamespace` of the Camel
component, which this Kamelet does not set.
+ description: How to log in to Service Bus. `CONNECTION_STRING`, the
default, uses `connectionString`. `AZURE_IDENTITY` uses the Azure identity of
the environment, such as the `AZURE_CLIENT_ID`, `AZURE_TENANT_ID` and
`AZURE_CLIENT_SECRET` environment variables, a managed identity or the Azure
CLI login, and needs `fullyQualifiedNamespace`. `TOKEN_CREDENTIAL` also needs
`fullyQualifiedNamespace`, and a `com.azure.core.credential.TokenCredential`
bean in the Camel registry.
type: string
default: "CONNECTION_STRING"
enum: ["AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL"]
+ fullyQualifiedNamespace:
+ title: Fully Qualified Namespace
+ description: The host name of the Service Bus namespace, such as
`my-namespace.servicebus.windows.net`, without `sb://` or `https://`. Required
with `credentialType` `AZURE_IDENTITY` or `TOKEN_CREDENTIAL`; not used with
`CONNECTION_STRING`, where the connection string names the namespace.
+ type: string
+ pattern: "^[A-Za-z0-9][A-Za-z0-9.-]*$"
+ example: my-namespace.servicebus.windows.net
+ sessionId:
+ title: Session ID
+ description: The session ID to send every message with, up to 128
characters, kept as written. Required to send to a queue, or to a topic
subscription, with sessions enabled; a reader receives the messages of one
session in the order they were sent. A queue without sessions accepts the
session ID too, and ignores it.
+ type: string
+ pattern: "^.{1,128}$"
+ example: customer-42
types:
in:
mediaType: application/octet-stream
@@ -84,7 +99,9 @@ spec:
uri: azure-servicebus
parameters:
topicOrQueueName: "{{topicOrQueueName}}"
- connectionString: "RAW({{connectionString}})"
+ connectionString: "RAW({{?connectionString}})"
credentialType: "{{credentialType}}"
+ fullyQualifiedNamespace: "{{?fullyQualifiedNamespace}}"
producerOperation: sendMessages
serviceBusType: "{{serviceBusType}}"
+ sessionId: "RAW({{?sessionId}})"
diff --git a/kamelets/azure-servicebus-source.kamelet.yaml
b/kamelets/azure-servicebus-source.kamelet.yaml
index 58ecd2c22..fb853b00c 100644
--- a/kamelets/azure-servicebus-source.kamelet.yaml
+++ b/kamelets/azure-servicebus-source.kamelet.yaml
@@ -34,14 +34,19 @@ spec:
description: |-
Receives the messages of a queue, or of a topic subscription, in Azure
Service Bus, one message each.
- Use it to process work or events that other applications send through
Service Bus. To read new blobs from Event Grid events that arrive in a Service
Bus queue, use `azure-storage-blob-event-based-source`.
+ Use it to process work or events that other applications send through
Service Bus, including a queue with sessions, or to read the messages that
Service Bus has dead-lettered. To read new blobs from Event Grid events that
arrive in a Service Bus queue, use `azure-storage-blob-event-based-source`.
- Output: the body is the body of the Service Bus message, as bytes. The
headers give its ID (`CamelAzureServiceBusMessageId`), its custom properties
(`CamelAzureServiceBusApplicationProperties`, a Map), its content type,
correlation ID, subject, enqueued time and delivery count.
+ Output: the body is the body of the Service Bus message, as bytes. The
headers give its ID (`CamelAzureServiceBusMessageId`), its custom properties
(`CamelAzureServiceBusApplicationProperties`, a Map), its content type,
correlation ID, subject, enqueued time and delivery count, its session ID
(`CamelAzureServiceBusSessionId`) when it was sent with one, and, for a
dead-lettered message, why it was dead-lettered
(`CamelAzureServiceBusDeadLetterReason` and `CamelAzureServiceBusDeadLet [...]
Good to know: with the default `serviceBusReceiveMode` of `PEEK_LOCK`, a
message is removed only once it has been processed; a message whose processing
fails is given back and received again, until Service Bus moves it to the
dead-letter queue after the maximum delivery count (10 by default). With
`RECEIVE_AND_DELETE`, a message is removed as soon as it is received, so a
failure loses it. For a topic, set `serviceBusType` to `topic` and
`subscriptionName`.
+
+ A queue or subscription created with sessions enabled can be read only
with `sessionEnabled` set to `true`: without it, the integration starts but
receives nothing, and logs a warning from Service Bus every few seconds (`It is
not possible for an entity that requires sessions to create a non-sessionful
message receiver`). With sessions, the messages of one session are received in
the order they were sent, and the next one only once the previous one has been
processed, unless a step [...]
+
+ To read the dead-letter queue, set `subQueue` to `DEAD_LETTER_QUEUE`,
and leave `sessionEnabled` unset even when the queue has sessions, because the
dead-letter queue has none. A dead-lettered message whose processing fails is
not moved anywhere else: it is given back and received again straight away,
over and over, and holds up the dead letters behind it.
+
+ To log in with an Azure identity instead of a connection string, set
`credentialType` to `AZURE_IDENTITY` and `fullyQualifiedNamespace`, and leave
`connectionString` unset.
required:
- topicOrQueueName
- - connectionString
type: object
properties:
topicOrQueueName:
@@ -51,7 +56,7 @@ spec:
example: orders
connectionString:
title: Connection String
- description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`."
+ description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`. Required
with the default `credentialType`, `CONNECTION_STRING`."
type: string
format: password
x-descriptors:
@@ -75,10 +80,31 @@ spec:
enum: ["queue", "topic"]
credentialType:
title: Credential Type
- description: How to log in to Service Bus. Keep `CONNECTION_STRING`,
the default, which uses `connectionString`. `AZURE_IDENTITY` and
`TOKEN_CREDENTIAL` also need the `fullyQualifiedNamespace` of the Camel
component, which this Kamelet does not set.
+ description: How to log in to Service Bus. `CONNECTION_STRING`, the
default, uses `connectionString`. `AZURE_IDENTITY` uses the Azure identity of
the environment, such as the `AZURE_CLIENT_ID`, `AZURE_TENANT_ID` and
`AZURE_CLIENT_SECRET` environment variables, a managed identity or the Azure
CLI login, and needs `fullyQualifiedNamespace`. `TOKEN_CREDENTIAL` also needs
`fullyQualifiedNamespace`, and a `com.azure.core.credential.TokenCredential`
bean in the Camel registry.
type: string
default: "CONNECTION_STRING"
enum: ["AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL"]
+ fullyQualifiedNamespace:
+ title: Fully Qualified Namespace
+ description: The host name of the Service Bus namespace, such as
`my-namespace.servicebus.windows.net`, without `sb://` or `https://`. Required
with `credentialType` `AZURE_IDENTITY` or `TOKEN_CREDENTIAL`; not used with
`CONNECTION_STRING`, where the connection string names the namespace.
+ type: string
+ pattern: "^[A-Za-z0-9][A-Za-z0-9.-]*$"
+ example: my-namespace.servicebus.windows.net
+ sessionEnabled:
+ title: Sessions Enabled
+ description: Set to `true` to read a queue or subscription created
with sessions enabled, which can be read no other way. The messages of one
session are then received in the order they were sent, one after the other.
Leave it unset for a queue or subscription without sessions, and for a
dead-letter queue, which cannot be read with it.
+ type: boolean
+ maxConcurrentSessions:
+ title: Max Concurrent Sessions
+ description: With `sessionEnabled`, how many sessions are read at the
same time, 1 when unset. The Kamelet keeps reading a session until it has had
no message for a minute, so with 1, the messages of another session wait
meanwhile. Messages of the same session are always received one at a time.
+ type: integer
+ minimum: 1
+ example: 8
+ subQueue:
+ title: Sub-Queue
+ description: Set to `DEAD_LETTER_QUEUE` to read the dead-letter queue
of the queue or subscription, where Service Bus moves the messages that could
not be delivered or processed, or to `TRANSFER_DEAD_LETTER_QUEUE` for the
messages that could not be forwarded or transferred. Leave it unset to read the
queue or subscription itself.
+ type: string
+ enum: ["DEAD_LETTER_QUEUE", "TRANSFER_DEAD_LETTER_QUEUE"]
types:
out:
mediaType: application/octet-stream
@@ -113,6 +139,18 @@ spec:
title: Delivery Count
description: How many times the message has been delivered, this
time included.
type: integer
+ CamelAzureServiceBusSessionId:
+ title: Session ID
+ description: The session ID of the message, when the sender set one,
as it must for a queue or subscription with sessions.
+ type: string
+ CamelAzureServiceBusDeadLetterReason:
+ title: Dead Letter Reason
+ description: For a message read from the dead-letter queue, why it
was dead-lettered, such as `MaxDeliveryCountExceeded` for a message whose
processing failed too many times.
+ type: string
+ CamelAzureServiceBusDeadLetterErrorDescription:
+ title: Dead Letter Error Description
+ description: For a message read from the dead-letter queue, the
description of why it was dead-lettered.
+ type: string
dependencies:
- "camel:azure-servicebus"
- "camel:kamelet"
@@ -121,11 +159,15 @@ spec:
uri: azure-servicebus
parameters:
topicOrQueueName: "{{topicOrQueueName}}"
- connectionString: "RAW({{connectionString}})"
+ connectionString: "RAW({{?connectionString}})"
credentialType: "{{credentialType}}"
+ fullyQualifiedNamespace: "{{?fullyQualifiedNamespace}}"
serviceBusReceiveMode: "{{serviceBusReceiveMode}}"
serviceBusType: "{{serviceBusType}}"
subscriptionName: "{{?subscriptionName}}"
+ sessionEnabled: "{{?sessionEnabled}}"
+ maxConcurrentSessions: "{{?maxConcurrentSessions}}"
+ subQueue: "{{?subQueue}}"
steps:
- setBody:
expression:
diff --git
a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java
b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java
index 94ab21c1a..5f52a2b41 100644
---
a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java
+++
b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java
@@ -206,7 +206,7 @@ public class KameletsCatalogTest {
verifyHeaders("aws-not-exists", 0);
verifyHeaders("azure-eventhubs-sink", 2);
verifyHeaders("azure-functions-sink", 8);
- verifyHeaders("azure-servicebus-source", 7);
+ verifyHeaders("azure-servicebus-source", 10);
verifyHeaders("azure-storage-blob-source", 8);
verifyHeaders("azure-storage-blob-sink", 2);
verifyHeaders("azure-storage-datalake-source", 26);
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 7256f6eb0..22e55fe28 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -385,7 +385,7 @@
"supportLevel" : "Stable",
"title" : "Azure Servicebus Sink",
"summary" : "Sends each message to a queue or a topic in Azure Service
Bus, the Azure message broker.",
- "description" : "Sends each message to a queue or a topic in Azure Service
Bus, the Azure message broker.\n\nUse it to hand work or events to other
applications through Service Bus, such as orders to process, or notifications
for all the subscribers of a topic. For simple storage queues, use
`azure-storage-queue-sink`.\n\nInput: the body is sent as text: text, bytes or
a stream are read as text. A Map is sent as its text form, so turn it into JSON
text first, for example with `json-s [...]
+ "description" : "Sends each message to a queue or a topic in Azure Service
Bus, the Azure message broker.\n\nUse it to hand work or events to other
applications through Service Bus, such as orders to process, or notifications
for all the subscribers of a topic. For simple storage queues, use
`azure-storage-queue-sink`.\n\nInput: the body is sent as text: text, bytes or
a stream are read as text. A Map is sent as its text form, so turn it into JSON
text first, for example with `json-s [...]
"group" : "Azure Servicebus",
"namespace" : "Azure",
"provider" : "Apache Software Foundation"
@@ -395,7 +395,7 @@
"supportLevel" : "Stable",
"title" : "Azure Servicebus Source",
"summary" : "Receives the messages of a queue, or of a topic subscription,
in Azure Service Bus, one message each.",
- "description" : "Receives the messages of a queue, or of a topic
subscription, in Azure Service Bus, one message each.\n\nUse it to process work
or events that other applications send through Service Bus. To read new blobs
from Event Grid events that arrive in a Service Bus queue, use
`azure-storage-blob-event-based-source`.\n\nOutput: the body is the body of the
Service Bus message, as bytes. The headers give its ID
(`CamelAzureServiceBusMessageId`), its custom properties (`CamelAzu [...]
+ "description" : "Receives the messages of a queue, or of a topic
subscription, in Azure Service Bus, one message each.\n\nUse it to process work
or events that other applications send through Service Bus, including a queue
with sessions, or to read the messages that Service Bus has dead-lettered. To
read new blobs from Event Grid events that arrive in a Service Bus queue, use
`azure-storage-blob-event-based-source`.\n\nOutput: the body is the body of the
Service Bus message, as bytes [...]
"group" : "Azure Servicebus",
"namespace" : "Azure",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-sink.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-sink.kamelet.yaml
index d17b59c72..6384e3054 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-sink.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-sink.kamelet.yaml
@@ -41,9 +41,12 @@ spec:
Output: the message is unchanged.
Good to know: the shared access policy of the connection string needs
the Send right.
+
+ A queue created with sessions enabled accepts only messages with a
session ID: without one, the send fails. A topic accepts them, but each of its
subscriptions with sessions enabled moves them to its dead-letter queue. Set
`sessionId` to send every message with that session ID; a reader of the queue
or subscription then receives the messages of the session in the order they
were sent. The session ID is fixed for the Kamelet: the
`CamelAzureServiceBusSessionId` header is not read, s [...]
+
+ To log in with an Azure identity instead of a connection string, set
`credentialType` to `AZURE_IDENTITY` and `fullyQualifiedNamespace`, and leave
`connectionString` unset.
required:
- topicOrQueueName
- - connectionString
type: object
properties:
topicOrQueueName:
@@ -53,7 +56,7 @@ spec:
example: orders
connectionString:
title: Connection String
- description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`."
+ description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`. Required
with the default `credentialType`, `CONNECTION_STRING`."
type: string
format: password
x-descriptors:
@@ -66,10 +69,22 @@ spec:
enum: ["queue", "topic"]
credentialType:
title: Credential Type
- description: How to log in to Service Bus. Keep `CONNECTION_STRING`,
the default, which uses `connectionString`. `AZURE_IDENTITY` and
`TOKEN_CREDENTIAL` also need the `fullyQualifiedNamespace` of the Camel
component, which this Kamelet does not set.
+ description: How to log in to Service Bus. `CONNECTION_STRING`, the
default, uses `connectionString`. `AZURE_IDENTITY` uses the Azure identity of
the environment, such as the `AZURE_CLIENT_ID`, `AZURE_TENANT_ID` and
`AZURE_CLIENT_SECRET` environment variables, a managed identity or the Azure
CLI login, and needs `fullyQualifiedNamespace`. `TOKEN_CREDENTIAL` also needs
`fullyQualifiedNamespace`, and a `com.azure.core.credential.TokenCredential`
bean in the Camel registry.
type: string
default: "CONNECTION_STRING"
enum: ["AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL"]
+ fullyQualifiedNamespace:
+ title: Fully Qualified Namespace
+ description: The host name of the Service Bus namespace, such as
`my-namespace.servicebus.windows.net`, without `sb://` or `https://`. Required
with `credentialType` `AZURE_IDENTITY` or `TOKEN_CREDENTIAL`; not used with
`CONNECTION_STRING`, where the connection string names the namespace.
+ type: string
+ pattern: "^[A-Za-z0-9][A-Za-z0-9.-]*$"
+ example: my-namespace.servicebus.windows.net
+ sessionId:
+ title: Session ID
+ description: The session ID to send every message with, up to 128
characters, kept as written. Required to send to a queue, or to a topic
subscription, with sessions enabled; a reader receives the messages of one
session in the order they were sent. A queue without sessions accepts the
session ID too, and ignores it.
+ type: string
+ pattern: "^.{1,128}$"
+ example: customer-42
types:
in:
mediaType: application/octet-stream
@@ -84,7 +99,9 @@ spec:
uri: azure-servicebus
parameters:
topicOrQueueName: "{{topicOrQueueName}}"
- connectionString: "RAW({{connectionString}})"
+ connectionString: "RAW({{?connectionString}})"
credentialType: "{{credentialType}}"
+ fullyQualifiedNamespace: "{{?fullyQualifiedNamespace}}"
producerOperation: sendMessages
serviceBusType: "{{serviceBusType}}"
+ sessionId: "RAW({{?sessionId}})"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-source.kamelet.yaml
index 58ecd2c22..fb853b00c 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/azure-servicebus-source.kamelet.yaml
@@ -34,14 +34,19 @@ spec:
description: |-
Receives the messages of a queue, or of a topic subscription, in Azure
Service Bus, one message each.
- Use it to process work or events that other applications send through
Service Bus. To read new blobs from Event Grid events that arrive in a Service
Bus queue, use `azure-storage-blob-event-based-source`.
+ Use it to process work or events that other applications send through
Service Bus, including a queue with sessions, or to read the messages that
Service Bus has dead-lettered. To read new blobs from Event Grid events that
arrive in a Service Bus queue, use `azure-storage-blob-event-based-source`.
- Output: the body is the body of the Service Bus message, as bytes. The
headers give its ID (`CamelAzureServiceBusMessageId`), its custom properties
(`CamelAzureServiceBusApplicationProperties`, a Map), its content type,
correlation ID, subject, enqueued time and delivery count.
+ Output: the body is the body of the Service Bus message, as bytes. The
headers give its ID (`CamelAzureServiceBusMessageId`), its custom properties
(`CamelAzureServiceBusApplicationProperties`, a Map), its content type,
correlation ID, subject, enqueued time and delivery count, its session ID
(`CamelAzureServiceBusSessionId`) when it was sent with one, and, for a
dead-lettered message, why it was dead-lettered
(`CamelAzureServiceBusDeadLetterReason` and `CamelAzureServiceBusDeadLet [...]
Good to know: with the default `serviceBusReceiveMode` of `PEEK_LOCK`, a
message is removed only once it has been processed; a message whose processing
fails is given back and received again, until Service Bus moves it to the
dead-letter queue after the maximum delivery count (10 by default). With
`RECEIVE_AND_DELETE`, a message is removed as soon as it is received, so a
failure loses it. For a topic, set `serviceBusType` to `topic` and
`subscriptionName`.
+
+ A queue or subscription created with sessions enabled can be read only
with `sessionEnabled` set to `true`: without it, the integration starts but
receives nothing, and logs a warning from Service Bus every few seconds (`It is
not possible for an entity that requires sessions to create a non-sessionful
message receiver`). With sessions, the messages of one session are received in
the order they were sent, and the next one only once the previous one has been
processed, unless a step [...]
+
+ To read the dead-letter queue, set `subQueue` to `DEAD_LETTER_QUEUE`,
and leave `sessionEnabled` unset even when the queue has sessions, because the
dead-letter queue has none. A dead-lettered message whose processing fails is
not moved anywhere else: it is given back and received again straight away,
over and over, and holds up the dead letters behind it.
+
+ To log in with an Azure identity instead of a connection string, set
`credentialType` to `AZURE_IDENTITY` and `fullyQualifiedNamespace`, and leave
`connectionString` unset.
required:
- topicOrQueueName
- - connectionString
type: object
properties:
topicOrQueueName:
@@ -51,7 +56,7 @@ spec:
example: orders
connectionString:
title: Connection String
- description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`."
+ description: "The connection string of the Service Bus namespace, from
the Azure portal: the namespace, then Settings, Shared access policies, a
policy, Primary Connection String. It starts with `Endpoint=sb://`. Required
with the default `credentialType`, `CONNECTION_STRING`."
type: string
format: password
x-descriptors:
@@ -75,10 +80,31 @@ spec:
enum: ["queue", "topic"]
credentialType:
title: Credential Type
- description: How to log in to Service Bus. Keep `CONNECTION_STRING`,
the default, which uses `connectionString`. `AZURE_IDENTITY` and
`TOKEN_CREDENTIAL` also need the `fullyQualifiedNamespace` of the Camel
component, which this Kamelet does not set.
+ description: How to log in to Service Bus. `CONNECTION_STRING`, the
default, uses `connectionString`. `AZURE_IDENTITY` uses the Azure identity of
the environment, such as the `AZURE_CLIENT_ID`, `AZURE_TENANT_ID` and
`AZURE_CLIENT_SECRET` environment variables, a managed identity or the Azure
CLI login, and needs `fullyQualifiedNamespace`. `TOKEN_CREDENTIAL` also needs
`fullyQualifiedNamespace`, and a `com.azure.core.credential.TokenCredential`
bean in the Camel registry.
type: string
default: "CONNECTION_STRING"
enum: ["AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL"]
+ fullyQualifiedNamespace:
+ title: Fully Qualified Namespace
+ description: The host name of the Service Bus namespace, such as
`my-namespace.servicebus.windows.net`, without `sb://` or `https://`. Required
with `credentialType` `AZURE_IDENTITY` or `TOKEN_CREDENTIAL`; not used with
`CONNECTION_STRING`, where the connection string names the namespace.
+ type: string
+ pattern: "^[A-Za-z0-9][A-Za-z0-9.-]*$"
+ example: my-namespace.servicebus.windows.net
+ sessionEnabled:
+ title: Sessions Enabled
+ description: Set to `true` to read a queue or subscription created
with sessions enabled, which can be read no other way. The messages of one
session are then received in the order they were sent, one after the other.
Leave it unset for a queue or subscription without sessions, and for a
dead-letter queue, which cannot be read with it.
+ type: boolean
+ maxConcurrentSessions:
+ title: Max Concurrent Sessions
+ description: With `sessionEnabled`, how many sessions are read at the
same time, 1 when unset. The Kamelet keeps reading a session until it has had
no message for a minute, so with 1, the messages of another session wait
meanwhile. Messages of the same session are always received one at a time.
+ type: integer
+ minimum: 1
+ example: 8
+ subQueue:
+ title: Sub-Queue
+ description: Set to `DEAD_LETTER_QUEUE` to read the dead-letter queue
of the queue or subscription, where Service Bus moves the messages that could
not be delivered or processed, or to `TRANSFER_DEAD_LETTER_QUEUE` for the
messages that could not be forwarded or transferred. Leave it unset to read the
queue or subscription itself.
+ type: string
+ enum: ["DEAD_LETTER_QUEUE", "TRANSFER_DEAD_LETTER_QUEUE"]
types:
out:
mediaType: application/octet-stream
@@ -113,6 +139,18 @@ spec:
title: Delivery Count
description: How many times the message has been delivered, this
time included.
type: integer
+ CamelAzureServiceBusSessionId:
+ title: Session ID
+ description: The session ID of the message, when the sender set one,
as it must for a queue or subscription with sessions.
+ type: string
+ CamelAzureServiceBusDeadLetterReason:
+ title: Dead Letter Reason
+ description: For a message read from the dead-letter queue, why it
was dead-lettered, such as `MaxDeliveryCountExceeded` for a message whose
processing failed too many times.
+ type: string
+ CamelAzureServiceBusDeadLetterErrorDescription:
+ title: Dead Letter Error Description
+ description: For a message read from the dead-letter queue, the
description of why it was dead-lettered.
+ type: string
dependencies:
- "camel:azure-servicebus"
- "camel:kamelet"
@@ -121,11 +159,15 @@ spec:
uri: azure-servicebus
parameters:
topicOrQueueName: "{{topicOrQueueName}}"
- connectionString: "RAW({{connectionString}})"
+ connectionString: "RAW({{?connectionString}})"
credentialType: "{{credentialType}}"
+ fullyQualifiedNamespace: "{{?fullyQualifiedNamespace}}"
serviceBusReceiveMode: "{{serviceBusReceiveMode}}"
serviceBusType: "{{serviceBusType}}"
subscriptionName: "{{?subscriptionName}}"
+ sessionEnabled: "{{?sessionEnabled}}"
+ maxConcurrentSessions: "{{?maxConcurrentSessions}}"
+ subQueue: "{{?subQueue}}"
steps:
- setBody:
expression: