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 162707489 chore: azure-servicebus-source can process messages in
parallel and dead-letter failures, the sink can send bytes and delay messages
(#3170) (#3239)
162707489 is described below
commit 162707489dfdd2b39233ecb30190b7eeb642c294
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 22:39:59 2026 +0100
chore: azure-servicebus-source can process messages in parallel and
dead-letter failures, the sink can send bytes and delay messages (#3170) (#3239)
azure-servicebus-source takes maxConcurrentCalls, how many messages are
processed at the same time (with sessions, for each session), and
enableDeadLettering, which moves a message whose processing fails to the
dead-letter queue straight away, with the exception as the reason,
instead of giving it back until the maximum delivery count.
azure-servicebus-sink takes binary, to send the body as bytes rather than
as text, and scheduledEnqueueDelay, a number of seconds Service Bus holds
each message before readers can receive it.
camel-azure-servicebus has a scheduledEnqueueTime endpoint option, but it
is a fixed OffsetDateTime that cannot be set from a string (no type
converter), and it is read only by the scheduleMessages operation. So,
when scheduledEnqueueDelay is set, the template sets the
CamelAzureServiceBusProducerOperation and
CamelAzureServiceBusScheduledEnqueueTime headers to now plus the delay
for the send, and removes them afterwards, so the message leaves the
Kamelet unchanged. The time is computed with the bean language, so the
sink now declares camel:bean.
All the new options are optional placeholders without a default: when
they are unset, the endpoint URIs are identical to before.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../camel-kamelets-catalog-sbom.json | 2 +-
.../azure-servicebus-sink-description.adoc | 49 ++++++++++++++++++++++
.../azure-servicebus-source-description.adoc | 47 +++++++++++++++++++++
kamelets/azure-servicebus-sink.kamelet.yaml | 49 +++++++++++++++++++++-
kamelets/azure-servicebus-source.kamelet.yaml | 20 +++++++--
.../main/resources/META-INF/kamelets-index.json | 4 +-
.../kamelets/azure-servicebus-sink.kamelet.yaml | 49 +++++++++++++++++++++-
.../kamelets/azure-servicebus-source.kamelet.yaml | 20 +++++++--
8 files changed, 227 insertions(+), 13 deletions(-)
diff --git a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
index c4c16c2d8..35112f88f 100644
--- a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
+++ b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
@@ -2487,7 +2487,7 @@
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:azure-servicebus-sink",
- "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
+ "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:azure-servicebus-source",
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
diff --git a/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
b/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
index 7b3e9e78d..33f155cf7 100644
--- a/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
+++ b/docs/modules/ROOT/partials/azure-servicebus-sink-description.adoc
@@ -51,3 +51,52 @@ moves them to its dead-letter queue. Set **sessionId** to
send every message wit
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.
+
+=== Example Sending Binary Data
+
+The body is sent as text, so bytes that are not UTF-8 text, such as an image
or a compressed file, are damaged. Set
+**binary** to `true` to send the bytes exactly as they are:
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "file:/data/images"
+ steps:
+ - to:
+ uri: "kamelet:azure-servicebus-sink"
+ parameters:
+ topicOrQueueName: "images"
+ connectionString: "{{servicebus.connection-string}}"
+ binary: true
+----
+
+Text is sent as its UTF-8 bytes either way. With **binary**, a Map body fails
to send: turn it into JSON text first,
+for example with `json-serialize-action`.
+
+=== Example with a Delay
+
+Set **scheduledEnqueueDelay** to have Service Bus hold each message for that
many seconds before readers can receive
+it:
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "timer:tick"
+ parameters:
+ period: 60000
+ steps:
+ - setBody:
+ constant: "Your order is ready for pickup"
+ - to:
+ uri: "kamelet:azure-servicebus-sink"
+ parameters:
+ topicOrQueueName: "reminders"
+ connectionString: "{{servicebus.connection-string}}"
+ scheduledEnqueueDelay: 600
+----
+
+The send returns at once, and the message appears in the queue ten minutes
later, with that time as its enqueued time
+(`CamelAzureServiceBusEnqueuedTime` for a reader). The delay is the same for
every message, and counts from the clock
+of the integration.
diff --git
a/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
b/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
index 8d4185241..8e081c53f 100644
--- a/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
+++ b/docs/modules/ROOT/partials/azure-servicebus-source-description.adoc
@@ -76,3 +76,50 @@ The dead-letter queue has no sessions, so leave
**sessionEnabled** unset, even f
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.
+
+=== Example Processing Messages in Parallel
+
+The messages are processed one at a time, in the order they arrive, unless a
step of the integration works
+asynchronously, such as a delay. Set **maxConcurrentCalls** to process that
many
+at the same time, for example when each message calls a slow service:
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "kamelet:azure-servicebus-source"
+ parameters:
+ topicOrQueueName: "orders"
+ connectionString: "{{servicebus.connection-string}}"
+ maxConcurrentCalls: 5
+ steps:
+ - to: "http://order-service/orders"
+----
+
+With 5, ten messages that take a second each are processed in about two
seconds instead of ten, and in no particular
+order. With **sessionEnabled**, **maxConcurrentCalls** counts for each
session: above 1, the messages of one session
+are processed at the same time too, and lose their order.
+
+=== Example Dead-Lettering Failed Messages
+
+By default, 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 of the queue (10 by
default). Set **enableDeadLettering** to `true`
+to move it there straight away:
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "kamelet:azure-servicebus-source"
+ parameters:
+ topicOrQueueName: "orders"
+ connectionString: "{{servicebus.connection-string}}"
+ enableDeadLettering: true
+ steps:
+ - to: "http://order-service/orders"
+----
+
+The dead-lettered message has the exception as its reason, such as
`java.lang.IllegalStateException: Invalid order`,
+and its stack trace as the error description; read them back with **subQueue**
set to `DEAD_LETTER_QUEUE`, in the
+`CamelAzureServiceBusDeadLetterReason` and
`CamelAzureServiceBusDeadLetterErrorDescription` headers. It works only with
+the default **serviceBusReceiveMode**, `PEEK_LOCK`, and does nothing while
reading the dead-letter queue itself.
diff --git a/kamelets/azure-servicebus-sink.kamelet.yaml
b/kamelets/azure-servicebus-sink.kamelet.yaml
index 6384e3054..623b138a5 100644
--- a/kamelets/azure-servicebus-sink.kamelet.yaml
+++ b/kamelets/azure-servicebus-sink.kamelet.yaml
@@ -34,9 +34,9 @@ spec:
description: |-
Sends each message to a queue or a topic in Azure Service Bus, the Azure
message broker.
- Use 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`.
+ Use 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,
now or after a delay. For simple storage queues, use `azure-storage-queue-sink`.
- Input: 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-serialize-action`. A List is sent as one message per
element. The optional `CamelAzureServiceBusApplicationProperties` header, a
Map, sets the custom properties of the message.
+ Input: the body is sent as text: text, bytes or a stream are read as
text, so bytes that are not UTF-8 text, such as an image, are damaged. With
`binary` set to `true`, the body is sent as bytes, exactly as they are, and
text as its UTF-8 bytes. A Map is sent as its text form, so turn it into JSON
text first, for example with `json-serialize-action`; with `binary`, a Map
cannot be sent at all. A List is sent as one message per element. The optional
`CamelAzureServiceBusApplicationP [...]
Output: the message is unchanged.
@@ -44,6 +44,8 @@ spec:
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 [...]
+ Set `scheduledEnqueueDelay` to have Service Bus hold each message for
that many seconds before readers can receive it, for example to send a
reminder. The delay is the same for every message, and counts from the clock of
the integration.
+
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
@@ -85,16 +87,48 @@ spec:
type: string
pattern: "^.{1,128}$"
example: customer-42
+ binary:
+ title: Binary
+ description: Set to `true` to send the body as bytes, exactly as they
are, such as an image or a compressed file. When unset, the body is sent as
text, and bytes that are not UTF-8 text are damaged. Text is sent as its UTF-8
bytes either way. With `binary`, a Map body fails to send, so turn it into JSON
text first.
+ type: boolean
+ scheduledEnqueueDelay:
+ title: Scheduled Enqueue Delay
+ description: How many seconds Service Bus holds each message before
readers can receive it. The message is accepted at once, and appears in the
queue or topic once the delay is over, with that time as its enqueued time.
When unset, the message can be received straight away.
+ type: integer
+ minimum: 1
+ example: 600
types:
in:
mediaType: application/octet-stream
dependencies:
- "camel:azure-servicebus"
+ - "camel:bean"
- "camel:kamelet"
template:
from:
uri: kamelet:source
steps:
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "'{{?scheduledEnqueueDelay}}' != ''"
+ steps:
+ - setHeader:
+ name: CamelAzureServiceBusProducerOperation
+ expression:
+ constant:
+ expression: scheduleMessages
+ - setHeader:
+ name: CamelAzureServiceBusScheduledEnqueueTime
+ expression:
+ simple:
+ expression:
"${bean:type:java.time.OffsetDateTime?method=now()}"
+ - setHeader:
+ name: CamelAzureServiceBusScheduledEnqueueTime
+ expression:
+ simple:
+ expression:
"${header.CamelAzureServiceBusScheduledEnqueueTime.plusSeconds({{?scheduledEnqueueDelay}})}"
- to:
uri: azure-servicebus
parameters:
@@ -105,3 +139,14 @@ spec:
producerOperation: sendMessages
serviceBusType: "{{serviceBusType}}"
sessionId: "RAW({{?sessionId}})"
+ binary: "{{?binary}}"
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "'{{?scheduledEnqueueDelay}}' != ''"
+ steps:
+ - removeHeader:
+ name: CamelAzureServiceBusProducerOperation
+ - removeHeader:
+ name: CamelAzureServiceBusScheduledEnqueueTime
diff --git a/kamelets/azure-servicebus-source.kamelet.yaml
b/kamelets/azure-servicebus-source.kamelet.yaml
index fb853b00c..412dccc6d 100644
--- a/kamelets/azure-servicebus-source.kamelet.yaml
+++ b/kamelets/azure-servicebus-source.kamelet.yaml
@@ -34,13 +34,15 @@ 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, 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`.
+ Use it to process work or events that other applications send through
Service Bus, one at a time or several at once, 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, 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`.
+ 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
`enableDeadLettering` set to `true`, it is moved to the dead-letter queue
straight away instead, with the exception as the reason, such as
`java.lang.IllegalStateException: Invalid order` [...]
- 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 [...]
+ The messages are processed one at a time, in the order they arrive,
unless a step of the integration works asynchronously, such as a delay. With
`maxConcurrentCalls` set above 1, that many are processed at the same time, in
no particular order.
+
+ 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.
@@ -105,6 +107,16 @@ spec:
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"]
+ maxConcurrentCalls:
+ title: Max Concurrent Calls
+ description: How many messages are processed at the same time, 1 when
unset. Above 1, the messages are no longer processed in the order they arrive.
With `sessionEnabled`, it counts for each session, so the messages of one
session are processed at the same time too, and lose the order that sessions
otherwise keep.
+ type: integer
+ minimum: 1
+ example: 8
+ enableDeadLettering:
+ title: Enable Dead Lettering
+ description: "Set to `true` to move a message whose processing fails
to the dead-letter queue straight away, instead of giving it back to be
received again until the maximum delivery count of the queue is reached. The
dead-lettered message has the exception as its reason
(`CamelAzureServiceBusDeadLetterReason` when read back), such as
`java.lang.IllegalStateException: Invalid order`, and its stack trace as the
error description. Works only with the default `serviceBusReceiveMode` [...]
+ type: boolean
types:
out:
mediaType: application/octet-stream
@@ -168,6 +180,8 @@ spec:
sessionEnabled: "{{?sessionEnabled}}"
maxConcurrentSessions: "{{?maxConcurrentSessions}}"
subQueue: "{{?subQueue}}"
+ maxConcurrentCalls: "{{?maxConcurrentCalls}}"
+ enableDeadLettering: "{{?enableDeadLettering}}"
steps:
- setBody:
expression:
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 ffc7def08..cba69f028 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, now or after a delay. 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, so bytes that are not UTF-8 text,
such as an image, are damaged. Wi [...]
"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, 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 [...]
+ "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, one at a time or
several at once, 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
[...]
"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 6384e3054..623b138a5 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
@@ -34,9 +34,9 @@ spec:
description: |-
Sends each message to a queue or a topic in Azure Service Bus, the Azure
message broker.
- Use 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`.
+ Use 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,
now or after a delay. For simple storage queues, use `azure-storage-queue-sink`.
- Input: 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-serialize-action`. A List is sent as one message per
element. The optional `CamelAzureServiceBusApplicationProperties` header, a
Map, sets the custom properties of the message.
+ Input: the body is sent as text: text, bytes or a stream are read as
text, so bytes that are not UTF-8 text, such as an image, are damaged. With
`binary` set to `true`, the body is sent as bytes, exactly as they are, and
text as its UTF-8 bytes. A Map is sent as its text form, so turn it into JSON
text first, for example with `json-serialize-action`; with `binary`, a Map
cannot be sent at all. A List is sent as one message per element. The optional
`CamelAzureServiceBusApplicationP [...]
Output: the message is unchanged.
@@ -44,6 +44,8 @@ spec:
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 [...]
+ Set `scheduledEnqueueDelay` to have Service Bus hold each message for
that many seconds before readers can receive it, for example to send a
reminder. The delay is the same for every message, and counts from the clock of
the integration.
+
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
@@ -85,16 +87,48 @@ spec:
type: string
pattern: "^.{1,128}$"
example: customer-42
+ binary:
+ title: Binary
+ description: Set to `true` to send the body as bytes, exactly as they
are, such as an image or a compressed file. When unset, the body is sent as
text, and bytes that are not UTF-8 text are damaged. Text is sent as its UTF-8
bytes either way. With `binary`, a Map body fails to send, so turn it into JSON
text first.
+ type: boolean
+ scheduledEnqueueDelay:
+ title: Scheduled Enqueue Delay
+ description: How many seconds Service Bus holds each message before
readers can receive it. The message is accepted at once, and appears in the
queue or topic once the delay is over, with that time as its enqueued time.
When unset, the message can be received straight away.
+ type: integer
+ minimum: 1
+ example: 600
types:
in:
mediaType: application/octet-stream
dependencies:
- "camel:azure-servicebus"
+ - "camel:bean"
- "camel:kamelet"
template:
from:
uri: kamelet:source
steps:
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "'{{?scheduledEnqueueDelay}}' != ''"
+ steps:
+ - setHeader:
+ name: CamelAzureServiceBusProducerOperation
+ expression:
+ constant:
+ expression: scheduleMessages
+ - setHeader:
+ name: CamelAzureServiceBusScheduledEnqueueTime
+ expression:
+ simple:
+ expression:
"${bean:type:java.time.OffsetDateTime?method=now()}"
+ - setHeader:
+ name: CamelAzureServiceBusScheduledEnqueueTime
+ expression:
+ simple:
+ expression:
"${header.CamelAzureServiceBusScheduledEnqueueTime.plusSeconds({{?scheduledEnqueueDelay}})}"
- to:
uri: azure-servicebus
parameters:
@@ -105,3 +139,14 @@ spec:
producerOperation: sendMessages
serviceBusType: "{{serviceBusType}}"
sessionId: "RAW({{?sessionId}})"
+ binary: "{{?binary}}"
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "'{{?scheduledEnqueueDelay}}' != ''"
+ steps:
+ - removeHeader:
+ name: CamelAzureServiceBusProducerOperation
+ - removeHeader:
+ name: CamelAzureServiceBusScheduledEnqueueTime
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 fb853b00c..412dccc6d 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,13 +34,15 @@ 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, 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`.
+ Use it to process work or events that other applications send through
Service Bus, one at a time or several at once, 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, 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`.
+ 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
`enableDeadLettering` set to `true`, it is moved to the dead-letter queue
straight away instead, with the exception as the reason, such as
`java.lang.IllegalStateException: Invalid order` [...]
- 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 [...]
+ The messages are processed one at a time, in the order they arrive,
unless a step of the integration works asynchronously, such as a delay. With
`maxConcurrentCalls` set above 1, that many are processed at the same time, in
no particular order.
+
+ 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.
@@ -105,6 +107,16 @@ spec:
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"]
+ maxConcurrentCalls:
+ title: Max Concurrent Calls
+ description: How many messages are processed at the same time, 1 when
unset. Above 1, the messages are no longer processed in the order they arrive.
With `sessionEnabled`, it counts for each session, so the messages of one
session are processed at the same time too, and lose the order that sessions
otherwise keep.
+ type: integer
+ minimum: 1
+ example: 8
+ enableDeadLettering:
+ title: Enable Dead Lettering
+ description: "Set to `true` to move a message whose processing fails
to the dead-letter queue straight away, instead of giving it back to be
received again until the maximum delivery count of the queue is reached. The
dead-lettered message has the exception as its reason
(`CamelAzureServiceBusDeadLetterReason` when read back), such as
`java.lang.IllegalStateException: Invalid order`, and its stack trace as the
error description. Works only with the default `serviceBusReceiveMode` [...]
+ type: boolean
types:
out:
mediaType: application/octet-stream
@@ -168,6 +180,8 @@ spec:
sessionEnabled: "{{?sessionEnabled}}"
maxConcurrentSessions: "{{?maxConcurrentSessions}}"
subQueue: "{{?subQueue}}"
+ maxConcurrentCalls: "{{?maxConcurrentCalls}}"
+ enableDeadLettering: "{{?enableDeadLettering}}"
steps:
- setBody:
expression: