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 73d97489b Fix #1931: the event-based sources give the ID that is the
same in each copy of an event (#3325)
73d97489b is described below
commit 73d97489b9518f348933069e2173fd93beb4b677
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 21 20:19:00 2026 +0100
Fix #1931: the event-based sources give the ID that is the same in each
copy of an event (#3325)
S3, Azure Storage, Cloud Storage and Ceph deliver their events at least
once. aws-s3-event-based-source, azure-storage-blob-event-based-source and
google-storage-event-based-source now set a header that is the same in
every copy of an event (ceph-event-based-source already had ceph-event-id),
also with getObject or getBlob, so that a route can skip the copies with an
idempotentConsumer step and the repository it chooses.
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../camel-kamelets-catalog-sbom.json | 2 +-
kamelets/aws-s3-event-based-source.kamelet.yaml | 30 ++++-
...re-storage-blob-event-based-source.kamelet.yaml | 41 +++++-
kamelets/ceph-event-based-source.kamelet.yaml | 2 +-
.../google-storage-event-based-source.kamelet.yaml | 31 ++++-
.../main/resources/META-INF/kamelets-index.json | 8 +-
.../aws-s3-event-based-source.kamelet.yaml | 30 ++++-
...re-storage-blob-event-based-source.kamelet.yaml | 41 +++++-
.../kamelets/ceph-event-based-source.kamelet.yaml | 2 +-
.../google-storage-event-based-source.kamelet.yaml | 31 ++++-
...ph-event-based-source-get-object.citrus.it.yaml | 6 +
.../aws-s3-ceph-event-based-source-get-object.yaml | 2 +
...s3-event-based-source-duplicates.citrus.it.yaml | 141 +++++++++++++++++++++
...l => aws-s3-event-based-source-duplicates.yaml} | 19 ++-
...s3-event-based-source-get-object.citrus.it.yaml | 8 +-
.../s3/aws-s3-event-based-source-get-object.yaml | 2 +
...ge-blob-event-based-source-route.citrus.it.yaml | 2 +
...zure-storage-blob-event-based-source-route.yaml | 5 +-
...storage-event-based-source-route.citrus.it.yaml | 2 +
.../google-storage-event-based-source-route.yaml | 3 +
20 files changed, 380 insertions(+), 28 deletions(-)
diff --git a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
index eaef6339c..95af223a7 100644
--- a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
+++ b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
@@ -2545,7 +2545,7 @@
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:google-storage-event-based-source",
- "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"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]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:google-storage-sink",
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
diff --git a/kamelets/aws-s3-event-based-source.kamelet.yaml
b/kamelets/aws-s3-event-based-source.kamelet.yaml
index 9a75953d5..8a9ef8714 100644
--- a/kamelets/aws-s3-event-based-source.kamelet.yaml
+++ b/kamelets/aws-s3-event-based-source.kamelet.yaml
@@ -38,9 +38,9 @@ spec:
Use it to react to new files in a bucket as soon as they arrive, without
listing the bucket again and again, for example to process uploaded documents
or imported data files. To read the files of a bucket by polling it, use
`aws-s3-source`.
- Output: the body is the EventBridge event, as JSON text: `detail-type`
says what happened (such as `Object Created` or `Object Deleted`),
`detail.bucket.name` is the bucket and `detail.object.key` the key of the file.
With `getObject` set to true, the event of a file uploaded with a simple upload
(PutObject) carries the content of the file instead, as a stream, with the
`CamelAwsS3ProducedBucketName` and `CamelAwsS3ProducedKey` headers; the other
events then come as parsed JSON (a [...]
+ Output: the body is the EventBridge event, as JSON text: `detail-type`
says what happened (such as `Object Created` or `Object Deleted`),
`detail.bucket.name` is the bucket and `detail.object.key` the key of the file.
With `getObject` set to true, the event of a file uploaded with a simple upload
(PutObject) carries the content of the file instead, as a stream, with the
`CamelAwsS3ProducedBucketName` and `CamelAwsS3ProducedKey` headers; the other
events then come as parsed JSON (a [...]
- Good to know: it needs a setup in AWS. In the properties of the bucket,
turn on sending events to Amazon EventBridge; then create an EventBridge rule
for the events of source `aws.s3` and that bucket, with the queue as its
target. Each event is deleted from the queue once it has been processed, unless
`deleteAfterRead` is false; an event that fails stays in the queue and is
received again when its visibility timeout (`visibilityTimeout`) ends. The
files stay in the bucket. `getObje [...]
+ Good to know: it needs a setup in AWS. In the properties of the bucket,
turn on sending events to Amazon EventBridge; then create an EventBridge rule
for the events of source `aws.s3` and that bucket, with the queue as its
target. Each event is deleted from the queue once it has been processed, unless
`deleteAfterRead` is false; an event that fails stays in the queue and is
received again when its visibility timeout (`visibilityTimeout`) ends. S3
delivers its events at least once, [...]
required:
- queueNameOrArn
- region
@@ -224,6 +224,10 @@ spec:
# the content of the file. See #3117.
out:
headers:
+ aws-s3-event-id:
+ title: Event ID
+ description: "What identifies the event, the same in each copy of
it, to skip the copies: the event type, the bucket, the key and the `sequencer`
of the event, such as `Object
Created/my-bucket/in/order.csv/0055AED6DCD90281E5`, or, for an event without a
sequencer, the `id` of the EventBridge event."
+ type: string
CamelAwsSqsMessageId:
title: SQS Message ID
description: The ID of the SQS message that carried the event.
@@ -271,6 +275,28 @@ spec:
waitTimeSeconds: "{{?waitTimeSeconds}}"
visibilityTimeout: "{{?visibilityTimeout}}"
steps:
+ # What identifies the event, also in a copy of it: S3 delivers its
events at least once, and the
+ # EventBridge `id` of a copy may differ. The sequencer orders the
events of one key (PUT and DELETE).
+ - choice:
+ when:
+ - expression:
+ jsonpath:
+ expression: "$.detail.object.sequencer"
+ suppressExceptions: true
+ steps:
+ - setHeader:
+ name: aws-s3-event-id
+ expression:
+ simple:
+ expression:
"${jsonpath($['detail-type'])}/${jsonpath($.detail.bucket.name)}/${jsonpath($.detail.object.key)}/${jsonpath($.detail.object.sequencer)}"
+ otherwise:
+ steps:
+ - setHeader:
+ name: aws-s3-event-id
+ expression:
+ jsonpath:
+ expression: "$.id"
+ suppressExceptions: true
- choice:
precondition: true
when:
diff --git a/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
b/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
index 07317ab2c..1a6fd2a3c 100644
--- a/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
+++ b/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
@@ -37,9 +37,9 @@ spec:
Use it to react quickly to new blobs, such as uploaded files, without
reading the container over and over. It needs an Event Grid subscription on the
storage account that sends the events, in the Event Grid schema, to a Service
Bus queue, or to a topic so that other applications can receive the same events
from subscriptions of their own. To read the container on a timer instead, use
`azure-storage-blob-source`.
- Output: when `getBlob` is false, the default, the body is the Event Grid
event as JSON (an Azure `BinaryData`, which converts to text or bytes). When
`getBlob` is true, the body of a `Microsoft.Storage.BlobCreated` event for a
blob of `containerName` is the content of that blob, as a stream of bytes, with
the `CamelAzureStorageBlob...` headers of the blob, such as
`CamelAzureStorageBlobContentType`, but no header with its name; the other
events are passed on as parsed JSON (a Jacks [...]
+ Output: when `getBlob` is false, the default, the body is the Event Grid
event as JSON (an Azure `BinaryData`, which converts to text or bytes). When
`getBlob` is true, the body of a `Microsoft.Storage.BlobCreated` event for a
blob of `containerName` is the content of that blob, as a stream of bytes, with
the `CamelAzureStorageBlob...` headers of the blob, such as
`CamelAzureStorageBlobContentType`, but no header with its name; the other
events are passed on as parsed JSON (a Jacks [...]
- Good to know: with the default `serviceBusReceiveMode` of
`RECEIVE_AND_DELETE`, an event is removed from the queue, or from the
subscription of the topic, as soon as it is received, so an event whose
processing fails is lost. With `getBlob`, only blobs at the top of the
container can be read: an event for a blob in a virtual folder, such as
`in/a.txt`, fails. Events are processed one at a time, in order, unless
`maxConcurrentCalls` is set.
+ Good to know: with the default `serviceBusReceiveMode` of
`RECEIVE_AND_DELETE`, an event is removed from the queue, or from the
subscription of the topic, as soon as it is received, so an event whose
processing fails is lost. With `getBlob`, only blobs at the top of the
container can be read: an event for a blob in a virtual folder, such as
`in/a.txt`, fails. Events are processed one at a time, in order, unless
`maxConcurrentCalls` is set. Azure delivers storage events at least onc [...]
required:
- topicOrQueueName
- connectionString
@@ -135,7 +135,11 @@ spec:
# No 'default:' here on purpose: `getBlob` decides whether the body is the
Event Grid event or the
# content of the blob. See #3117.
out:
- headers: {}
+ headers:
+ azure-storage-blob-event-id:
+ title: Event ID
+ description: "What identifies the event, the same in each copy of
it, to skip the copies: the event type, the subject and the `sequencer` of the
event, such as
`Microsoft.Storage.BlobCreated//blobServices/default/containers/orders/blobs/order-1.txt/00000000000000000000000000015508000000000005101c`,
or, for an event without a sequencer, its `id`."
+ type: string
types:
out:
mediaType: application/octet-stream
@@ -156,6 +160,37 @@ spec:
serviceBusType: "{{?serviceBusType}}"
maxConcurrentCalls: "{{?maxConcurrentCalls}}"
steps:
+ # What identifies the event, also in a copy of it: storage events are
delivered at least once, and a
+ # copy may have another `id`. The sequencer orders the events of one
blob. The body stays a BinaryData.
+ - setVariable:
+ name: azure-storage-blob-event
+ expression:
+ simple:
+ expression: "${body.toString()}"
+ - choice:
+ when:
+ - expression:
+ jsonpath:
+ expression: "$.data.sequencer"
+ source: "variable:azure-storage-blob-event"
+ suppressExceptions: true
+ steps:
+ - setHeader:
+ name: azure-storage-blob-event-id
+ expression:
+ simple:
+ expression:
"${jsonpath(variable:azure-storage-blob-event,$.eventType)}/${jsonpath(variable:azure-storage-blob-event,$.subject)}/${jsonpath(variable:azure-storage-blob-event,$.data.sequencer)}"
+ otherwise:
+ steps:
+ - setHeader:
+ name: azure-storage-blob-event-id
+ expression:
+ jsonpath:
+ expression: "$.id"
+ source: "variable:azure-storage-blob-event"
+ suppressExceptions: true
+ - removeVariable:
+ name: azure-storage-blob-event
- choice:
precondition: true
when:
diff --git a/kamelets/ceph-event-based-source.kamelet.yaml
b/kamelets/ceph-event-based-source.kamelet.yaml
index f8282ce7d..c243da36b 100644
--- a/kamelets/ceph-event-based-source.kamelet.yaml
+++ b/kamelets/ceph-event-based-source.kamelet.yaml
@@ -38,7 +38,7 @@ spec:
Output: the body is the notification as JSON text, unchanged: a
`Records` array that gives the event name (such as `ObjectCreated:Put`), the
bucket name and the key of the file. The headers `ceph-event-id`,
`ceph-opaque-data`, `ceph-object-metadata` and `ceph-object-tags` give the
fields Ceph adds to the event; metadata and tags are a List of entries with a
`key` and a `val`. Each header is also set with a `ce-` name, such as
`ce-cepheventid`. With `getObject` true, the body of an [...]
- Good to know: the notification and its Kafka topic are set up on the
Ceph side; this Kamelet only reads the topic. A record that is not a Ceph
notification (without a `Records` array) fails. `saslAuthType` has no default
and must be set; `NONE` connects to Kafka with no login and no TLS. Without
`consumerGroup`, each start uses a new group, so with the default
`autoOffsetReset` of `latest` the events sent while it was stopped are not read.
+ Good to know: the notification and its Kafka topic are set up on the
Ceph side; this Kamelet only reads the topic. A record that is not a Ceph
notification (without a `Records` array) fails. `saslAuthType` has no default
and must be set; `NONE` connects to Kafka with no login and no TLS. Without
`consumerGroup`, each start uses a new group, so with the default
`autoOffsetReset` of `latest` the events sent while it was stopped are not
read. An event can come more than once, such as [...]
required:
- topic
- bootstrapServers
diff --git a/kamelets/google-storage-event-based-source.kamelet.yaml
b/kamelets/google-storage-event-based-source.kamelet.yaml
index 0d7b48f4b..1c311b52a 100644
--- a/kamelets/google-storage-event-based-source.kamelet.yaml
+++ b/kamelets/google-storage-event-based-source.kamelet.yaml
@@ -36,9 +36,9 @@ spec:
Use it to react as soon as a file is uploaded to, changed in or deleted
from a bucket, without reading the whole bucket over and over. It needs a
Pub/Sub notification on the bucket, created for example with `gcloud storage
buckets notifications create gs://my-bucket --topic=my-topic`, and a
subscription on that topic. To read and delete the files of a bucket instead,
use `google-storage-source`.
- Output: by default, the body is the notification as JSON text (bytes):
the metadata of the file, such as its name, size and content type. The
`eventType` header says what happened (`OBJECT_FINALIZE` for a new or replaced
file, `OBJECT_DELETE` for a deleted one), and the `objectId` and `bucketId`
headers give the name of the file and of its bucket. With `getObject` set to
true, the body of a new file in `bucketNameOrArn` is the content of the file,
as bytes, with the `CamelGoogleClo [...]
+ Output: by default, the body is the notification as JSON text (bytes):
the metadata of the file, such as its name, size and content type. The
`eventType` header says what happened (`OBJECT_FINALIZE` for a new or replaced
file, `OBJECT_DELETE` for a deleted one), and the `objectId` and `bucketId`
headers give the name of the file and of its bucket. With `getObject` set to
true, the body of a new file in `bucketNameOrArn` is the content of the file,
as bytes, with the `CamelGoogleClo [...]
- Good to know: every notification of the subscription comes out, also for
other events and other buckets; `bucketNameOrArn` is only used to choose which
new files to download. Downloading does not delete the file. A notification
whose processing fails is not acknowledged, so Pub/Sub delivers it again. With
`ackMode` `NONE`, the route acknowledges each notification itself, through the
`CamelGooglePubsubAcknowledge` header. On a subscription with a dead-letter
topic, `maxDeliveryAttem [...]
+ Good to know: every notification of the subscription comes out, also for
other events and other buckets; `bucketNameOrArn` is only used to choose which
new files to download. Downloading does not delete the file. A notification
whose processing fails is not acknowledged, so Pub/Sub delivers it again. Cloud
Storage also sends its notifications at least once, so the same change can come
twice, in two Pub/Sub messages with different IDs; `google-storage-event-id` is
the same in both. [...]
required:
- projectId
- subscriptionName
@@ -103,6 +103,10 @@ spec:
# text or the content of the file. See #3117.
out:
headers:
+ google-storage-event-id:
+ title: Event ID
+ description: "What identifies the change, the same in each copy of
its notification, to skip the copies: the event type, the bucket, the name, the
generation and the metageneration of the file, such as
`OBJECT_FINALIZE/my-bucket/inbox/orders.csv/1763719200000000/1`. For a
notification without payload (payload format `NONE`), the time of the change
(`eventTime`) takes the place of the metageneration."
+ type: string
eventType:
title: Event Type
description: What happened to the file, such as `OBJECT_FINALIZE`
for a new or replaced file, `OBJECT_DELETE` for a deleted one, or
`OBJECT_METADATA_UPDATE`.
@@ -136,10 +140,33 @@ spec:
- "camel:google-pubsub"
- "camel:google-storage"
- "camel:jackson3"
+ - "camel:jsonpath"
template:
from:
uri:
"google-pubsub://{{projectId}}:{{subscriptionName}}?ackMode={{?ackMode}}&concurrentConsumers={{concurrentConsumers}}&maxDeliveryAttempts={{?maxDeliveryAttempts}}&maxMessagesPerPoll={{maxMessagesPerPoll}}&serviceAccountKey=RAW(base64:{{serviceAccountKey}})&synchronousPull={{synchronousPull}}"
steps:
+ # What identifies the change, also in a copy of its notification:
Cloud Storage sends them at least
+ # once, in a new Pub/Sub message each time. A file has one generation
per version, and each change of
+ # its metadata adds one to its metageneration, which only the JSON
payload has; a notification without
+ # payload has the time of the change instead.
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${header.payloadFormat} == 'JSON_API_V1'"
+ steps:
+ - setHeader:
+ name: google-storage-event-id
+ expression:
+ simple:
+ expression:
"${header.eventType}/${header.bucketId}/${header.objectId}/${header.objectGeneration}/${jsonpath($.metageneration)}"
+ otherwise:
+ steps:
+ - setHeader:
+ name: google-storage-event-id
+ expression:
+ simple:
+ expression:
"${header.eventType}/${header.bucketId}/${header.objectId}/${header.objectGeneration}/${header.eventTime}"
- choice:
precondition: true
when:
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 695017ba6..38192f1cc 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
@@ -195,7 +195,7 @@
"supportLevel" : "Preview",
"title" : "AWS S3 Event Based Source",
"summary" : "Receives the events of an Amazon S3 bucket, such as a new or
a deleted file, from the Amazon SQS queue that Amazon EventBridge sends them
to, one message per event.",
- "description" : "Receives the events of an Amazon S3 bucket, such as a new
or a deleted file, from the Amazon SQS queue that Amazon EventBridge sends them
to, one message per event.\n\nUse it to react to new files in a bucket as soon
as they arrive, without listing the bucket again and again, for example to
process uploaded documents or imported data files. To read the files of a
bucket by polling it, use `aws-s3-source`.\n\nOutput: the body is the
EventBridge event, as JSON text: `d [...]
+ "description" : "Receives the events of an Amazon S3 bucket, such as a new
or a deleted file, from the Amazon SQS queue that Amazon EventBridge sends them
to, one message per event.\n\nUse it to react to new files in a bucket as soon
as they arrive, without listing the bucket again and again, for example to
process uploaded documents or imported data files. To read the files of a
bucket by polling it, use `aws-s3-source`.\n\nOutput: the body is the
EventBridge event, as JSON text: `d [...]
"group" : "AWS S3 Event-Based",
"namespace" : "AWS",
"provider" : "Apache Software Foundation"
@@ -415,7 +415,7 @@
"supportLevel" : "Preview",
"title" : "Azure Storage Blob Event-based Source",
"summary" : "Receives the Event Grid events of an Azure Storage account
from a Service Bus queue or topic, and can read the content of each new blob in
a container.",
- "description" : "Receives the Event Grid events of an Azure Storage
account from a Service Bus queue or topic, and can read the content of each new
blob in a container.\n\nUse it to react quickly to new blobs, such as uploaded
files, without reading the container over and over. It needs an Event Grid
subscription on the storage account that sends the events, in the Event Grid
schema, to a Service Bus queue, or to a topic so that other applications can
receive the same events from sub [...]
+ "description" : "Receives the Event Grid events of an Azure Storage
account from a Service Bus queue or topic, and can read the content of each new
blob in a container.\n\nUse it to react quickly to new blobs, such as uploaded
files, without reading the container over and over. It needs an Event Grid
subscription on the storage account that sends the events, in the Event Grid
schema, to a Service Bus queue, or to a topic so that other applications can
receive the same events from sub [...]
"group" : "Azure Storage Blob Event Based",
"namespace" : "Azure",
"provider" : "Apache Software Foundation"
@@ -515,7 +515,7 @@
"supportLevel" : "Preview",
"title" : "Ceph Event Based Source",
"summary" : "Receives the bucket notifications that a Ceph Object Gateway
sends to a Kafka topic, one message per event, such as a file added to or
deleted from a bucket.",
- "description" : "Receives the bucket notifications that a Ceph Object
Gateway sends to a Kafka topic, one message per event, such as a file added to
or deleted from a bucket.\n\nUse it to react as soon as a file is uploaded to
or removed from a Ceph bucket, without reading the bucket over and over. Set
`getObject` to true to receive the content of each new file. To read and remove
the files of a bucket instead, use `ceph-source`.\n\nOutput: the body is the
notification as JSON text, [...]
+ "description" : "Receives the bucket notifications that a Ceph Object
Gateway sends to a Kafka topic, one message per event, such as a file added to
or deleted from a bucket.\n\nUse it to react as soon as a file is uploaded to
or removed from a Ceph bucket, without reading the bucket over and over. Set
`getObject` to true to receive the content of each new file. To read and remove
the files of a bucket instead, use `ceph-source`.\n\nOutput: the body is the
notification as JSON text, [...]
"group" : "Ceph",
"namespace" : "Cloud",
"provider" : "Apache Software Foundation"
@@ -945,7 +945,7 @@
"supportLevel" : "Preview",
"title" : "Google Storage Event-based Source",
"summary" : "Receives the change notifications of a Google Cloud Storage
bucket from a Pub/Sub subscription, one message per change, and can download
each new file.",
- "description" : "Receives the change notifications of a Google Cloud
Storage bucket from a Pub/Sub subscription, one message per change, and can
download each new file.\n\nUse it to react as soon as a file is uploaded to,
changed in or deleted from a bucket, without reading the whole bucket over and
over. It needs a Pub/Sub notification on the bucket, created for example with
`gcloud storage buckets notifications create gs://my-bucket --topic=my-topic`,
and a subscription on that top [...]
+ "description" : "Receives the change notifications of a Google Cloud
Storage bucket from a Pub/Sub subscription, one message per change, and can
download each new file.\n\nUse it to react as soon as a file is uploaded to,
changed in or deleted from a bucket, without reading the whole bucket over and
over. It needs a Pub/Sub notification on the bucket, created for example with
`gcloud storage buckets notifications create gs://my-bucket --topic=my-topic`,
and a subscription on that top [...]
"group" : "Google Storage Event-based",
"namespace" : "GCP",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/aws-s3-event-based-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/aws-s3-event-based-source.kamelet.yaml
index 9a75953d5..8a9ef8714 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/aws-s3-event-based-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/aws-s3-event-based-source.kamelet.yaml
@@ -38,9 +38,9 @@ spec:
Use it to react to new files in a bucket as soon as they arrive, without
listing the bucket again and again, for example to process uploaded documents
or imported data files. To read the files of a bucket by polling it, use
`aws-s3-source`.
- Output: the body is the EventBridge event, as JSON text: `detail-type`
says what happened (such as `Object Created` or `Object Deleted`),
`detail.bucket.name` is the bucket and `detail.object.key` the key of the file.
With `getObject` set to true, the event of a file uploaded with a simple upload
(PutObject) carries the content of the file instead, as a stream, with the
`CamelAwsS3ProducedBucketName` and `CamelAwsS3ProducedKey` headers; the other
events then come as parsed JSON (a [...]
+ Output: the body is the EventBridge event, as JSON text: `detail-type`
says what happened (such as `Object Created` or `Object Deleted`),
`detail.bucket.name` is the bucket and `detail.object.key` the key of the file.
With `getObject` set to true, the event of a file uploaded with a simple upload
(PutObject) carries the content of the file instead, as a stream, with the
`CamelAwsS3ProducedBucketName` and `CamelAwsS3ProducedKey` headers; the other
events then come as parsed JSON (a [...]
- Good to know: it needs a setup in AWS. In the properties of the bucket,
turn on sending events to Amazon EventBridge; then create an EventBridge rule
for the events of source `aws.s3` and that bucket, with the queue as its
target. Each event is deleted from the queue once it has been processed, unless
`deleteAfterRead` is false; an event that fails stays in the queue and is
received again when its visibility timeout (`visibilityTimeout`) ends. The
files stay in the bucket. `getObje [...]
+ Good to know: it needs a setup in AWS. In the properties of the bucket,
turn on sending events to Amazon EventBridge; then create an EventBridge rule
for the events of source `aws.s3` and that bucket, with the queue as its
target. Each event is deleted from the queue once it has been processed, unless
`deleteAfterRead` is false; an event that fails stays in the queue and is
received again when its visibility timeout (`visibilityTimeout`) ends. S3
delivers its events at least once, [...]
required:
- queueNameOrArn
- region
@@ -224,6 +224,10 @@ spec:
# the content of the file. See #3117.
out:
headers:
+ aws-s3-event-id:
+ title: Event ID
+ description: "What identifies the event, the same in each copy of
it, to skip the copies: the event type, the bucket, the key and the `sequencer`
of the event, such as `Object
Created/my-bucket/in/order.csv/0055AED6DCD90281E5`, or, for an event without a
sequencer, the `id` of the EventBridge event."
+ type: string
CamelAwsSqsMessageId:
title: SQS Message ID
description: The ID of the SQS message that carried the event.
@@ -271,6 +275,28 @@ spec:
waitTimeSeconds: "{{?waitTimeSeconds}}"
visibilityTimeout: "{{?visibilityTimeout}}"
steps:
+ # What identifies the event, also in a copy of it: S3 delivers its
events at least once, and the
+ # EventBridge `id` of a copy may differ. The sequencer orders the
events of one key (PUT and DELETE).
+ - choice:
+ when:
+ - expression:
+ jsonpath:
+ expression: "$.detail.object.sequencer"
+ suppressExceptions: true
+ steps:
+ - setHeader:
+ name: aws-s3-event-id
+ expression:
+ simple:
+ expression:
"${jsonpath($['detail-type'])}/${jsonpath($.detail.bucket.name)}/${jsonpath($.detail.object.key)}/${jsonpath($.detail.object.sequencer)}"
+ otherwise:
+ steps:
+ - setHeader:
+ name: aws-s3-event-id
+ expression:
+ jsonpath:
+ expression: "$.id"
+ suppressExceptions: true
- choice:
precondition: true
when:
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
index 07317ab2c..1a6fd2a3c 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/azure-storage-blob-event-based-source.kamelet.yaml
@@ -37,9 +37,9 @@ spec:
Use it to react quickly to new blobs, such as uploaded files, without
reading the container over and over. It needs an Event Grid subscription on the
storage account that sends the events, in the Event Grid schema, to a Service
Bus queue, or to a topic so that other applications can receive the same events
from subscriptions of their own. To read the container on a timer instead, use
`azure-storage-blob-source`.
- Output: when `getBlob` is false, the default, the body is the Event Grid
event as JSON (an Azure `BinaryData`, which converts to text or bytes). When
`getBlob` is true, the body of a `Microsoft.Storage.BlobCreated` event for a
blob of `containerName` is the content of that blob, as a stream of bytes, with
the `CamelAzureStorageBlob...` headers of the blob, such as
`CamelAzureStorageBlobContentType`, but no header with its name; the other
events are passed on as parsed JSON (a Jacks [...]
+ Output: when `getBlob` is false, the default, the body is the Event Grid
event as JSON (an Azure `BinaryData`, which converts to text or bytes). When
`getBlob` is true, the body of a `Microsoft.Storage.BlobCreated` event for a
blob of `containerName` is the content of that blob, as a stream of bytes, with
the `CamelAzureStorageBlob...` headers of the blob, such as
`CamelAzureStorageBlobContentType`, but no header with its name; the other
events are passed on as parsed JSON (a Jacks [...]
- Good to know: with the default `serviceBusReceiveMode` of
`RECEIVE_AND_DELETE`, an event is removed from the queue, or from the
subscription of the topic, as soon as it is received, so an event whose
processing fails is lost. With `getBlob`, only blobs at the top of the
container can be read: an event for a blob in a virtual folder, such as
`in/a.txt`, fails. Events are processed one at a time, in order, unless
`maxConcurrentCalls` is set.
+ Good to know: with the default `serviceBusReceiveMode` of
`RECEIVE_AND_DELETE`, an event is removed from the queue, or from the
subscription of the topic, as soon as it is received, so an event whose
processing fails is lost. With `getBlob`, only blobs at the top of the
container can be read: an event for a blob in a virtual folder, such as
`in/a.txt`, fails. Events are processed one at a time, in order, unless
`maxConcurrentCalls` is set. Azure delivers storage events at least onc [...]
required:
- topicOrQueueName
- connectionString
@@ -135,7 +135,11 @@ spec:
# No 'default:' here on purpose: `getBlob` decides whether the body is the
Event Grid event or the
# content of the blob. See #3117.
out:
- headers: {}
+ headers:
+ azure-storage-blob-event-id:
+ title: Event ID
+ description: "What identifies the event, the same in each copy of
it, to skip the copies: the event type, the subject and the `sequencer` of the
event, such as
`Microsoft.Storage.BlobCreated//blobServices/default/containers/orders/blobs/order-1.txt/00000000000000000000000000015508000000000005101c`,
or, for an event without a sequencer, its `id`."
+ type: string
types:
out:
mediaType: application/octet-stream
@@ -156,6 +160,37 @@ spec:
serviceBusType: "{{?serviceBusType}}"
maxConcurrentCalls: "{{?maxConcurrentCalls}}"
steps:
+ # What identifies the event, also in a copy of it: storage events are
delivered at least once, and a
+ # copy may have another `id`. The sequencer orders the events of one
blob. The body stays a BinaryData.
+ - setVariable:
+ name: azure-storage-blob-event
+ expression:
+ simple:
+ expression: "${body.toString()}"
+ - choice:
+ when:
+ - expression:
+ jsonpath:
+ expression: "$.data.sequencer"
+ source: "variable:azure-storage-blob-event"
+ suppressExceptions: true
+ steps:
+ - setHeader:
+ name: azure-storage-blob-event-id
+ expression:
+ simple:
+ expression:
"${jsonpath(variable:azure-storage-blob-event,$.eventType)}/${jsonpath(variable:azure-storage-blob-event,$.subject)}/${jsonpath(variable:azure-storage-blob-event,$.data.sequencer)}"
+ otherwise:
+ steps:
+ - setHeader:
+ name: azure-storage-blob-event-id
+ expression:
+ jsonpath:
+ expression: "$.id"
+ source: "variable:azure-storage-blob-event"
+ suppressExceptions: true
+ - removeVariable:
+ name: azure-storage-blob-event
- choice:
precondition: true
when:
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/ceph-event-based-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/ceph-event-based-source.kamelet.yaml
index f8282ce7d..c243da36b 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/ceph-event-based-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/ceph-event-based-source.kamelet.yaml
@@ -38,7 +38,7 @@ spec:
Output: the body is the notification as JSON text, unchanged: a
`Records` array that gives the event name (such as `ObjectCreated:Put`), the
bucket name and the key of the file. The headers `ceph-event-id`,
`ceph-opaque-data`, `ceph-object-metadata` and `ceph-object-tags` give the
fields Ceph adds to the event; metadata and tags are a List of entries with a
`key` and a `val`. Each header is also set with a `ce-` name, such as
`ce-cepheventid`. With `getObject` true, the body of an [...]
- Good to know: the notification and its Kafka topic are set up on the
Ceph side; this Kamelet only reads the topic. A record that is not a Ceph
notification (without a `Records` array) fails. `saslAuthType` has no default
and must be set; `NONE` connects to Kafka with no login and no TLS. Without
`consumerGroup`, each start uses a new group, so with the default
`autoOffsetReset` of `latest` the events sent while it was stopped are not read.
+ Good to know: the notification and its Kafka topic are set up on the
Ceph side; this Kamelet only reads the topic. A record that is not a Ceph
notification (without a `Records` array) fails. `saslAuthType` has no default
and must be set; `NONE` connects to Kafka with no login and no TLS. Without
`consumerGroup`, each start uses a new group, so with the default
`autoOffsetReset` of `latest` the events sent while it was stopped are not
read. An event can come more than once, such as [...]
required:
- topic
- bootstrapServers
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/google-storage-event-based-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/google-storage-event-based-source.kamelet.yaml
index 0d7b48f4b..1c311b52a 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/google-storage-event-based-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/google-storage-event-based-source.kamelet.yaml
@@ -36,9 +36,9 @@ spec:
Use it to react as soon as a file is uploaded to, changed in or deleted
from a bucket, without reading the whole bucket over and over. It needs a
Pub/Sub notification on the bucket, created for example with `gcloud storage
buckets notifications create gs://my-bucket --topic=my-topic`, and a
subscription on that topic. To read and delete the files of a bucket instead,
use `google-storage-source`.
- Output: by default, the body is the notification as JSON text (bytes):
the metadata of the file, such as its name, size and content type. The
`eventType` header says what happened (`OBJECT_FINALIZE` for a new or replaced
file, `OBJECT_DELETE` for a deleted one), and the `objectId` and `bucketId`
headers give the name of the file and of its bucket. With `getObject` set to
true, the body of a new file in `bucketNameOrArn` is the content of the file,
as bytes, with the `CamelGoogleClo [...]
+ Output: by default, the body is the notification as JSON text (bytes):
the metadata of the file, such as its name, size and content type. The
`eventType` header says what happened (`OBJECT_FINALIZE` for a new or replaced
file, `OBJECT_DELETE` for a deleted one), and the `objectId` and `bucketId`
headers give the name of the file and of its bucket. With `getObject` set to
true, the body of a new file in `bucketNameOrArn` is the content of the file,
as bytes, with the `CamelGoogleClo [...]
- Good to know: every notification of the subscription comes out, also for
other events and other buckets; `bucketNameOrArn` is only used to choose which
new files to download. Downloading does not delete the file. A notification
whose processing fails is not acknowledged, so Pub/Sub delivers it again. With
`ackMode` `NONE`, the route acknowledges each notification itself, through the
`CamelGooglePubsubAcknowledge` header. On a subscription with a dead-letter
topic, `maxDeliveryAttem [...]
+ Good to know: every notification of the subscription comes out, also for
other events and other buckets; `bucketNameOrArn` is only used to choose which
new files to download. Downloading does not delete the file. A notification
whose processing fails is not acknowledged, so Pub/Sub delivers it again. Cloud
Storage also sends its notifications at least once, so the same change can come
twice, in two Pub/Sub messages with different IDs; `google-storage-event-id` is
the same in both. [...]
required:
- projectId
- subscriptionName
@@ -103,6 +103,10 @@ spec:
# text or the content of the file. See #3117.
out:
headers:
+ google-storage-event-id:
+ title: Event ID
+ description: "What identifies the change, the same in each copy of
its notification, to skip the copies: the event type, the bucket, the name, the
generation and the metageneration of the file, such as
`OBJECT_FINALIZE/my-bucket/inbox/orders.csv/1763719200000000/1`. For a
notification without payload (payload format `NONE`), the time of the change
(`eventTime`) takes the place of the metageneration."
+ type: string
eventType:
title: Event Type
description: What happened to the file, such as `OBJECT_FINALIZE`
for a new or replaced file, `OBJECT_DELETE` for a deleted one, or
`OBJECT_METADATA_UPDATE`.
@@ -136,10 +140,33 @@ spec:
- "camel:google-pubsub"
- "camel:google-storage"
- "camel:jackson3"
+ - "camel:jsonpath"
template:
from:
uri:
"google-pubsub://{{projectId}}:{{subscriptionName}}?ackMode={{?ackMode}}&concurrentConsumers={{concurrentConsumers}}&maxDeliveryAttempts={{?maxDeliveryAttempts}}&maxMessagesPerPoll={{maxMessagesPerPoll}}&serviceAccountKey=RAW(base64:{{serviceAccountKey}})&synchronousPull={{synchronousPull}}"
steps:
+ # What identifies the change, also in a copy of its notification:
Cloud Storage sends them at least
+ # once, in a new Pub/Sub message each time. A file has one generation
per version, and each change of
+ # its metadata adds one to its metageneration, which only the JSON
payload has; a notification without
+ # payload has the time of the change instead.
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${header.payloadFormat} == 'JSON_API_V1'"
+ steps:
+ - setHeader:
+ name: google-storage-event-id
+ expression:
+ simple:
+ expression:
"${header.eventType}/${header.bucketId}/${header.objectId}/${header.objectGeneration}/${jsonpath($.metageneration)}"
+ otherwise:
+ steps:
+ - setHeader:
+ name: google-storage-event-id
+ expression:
+ simple:
+ expression:
"${header.eventType}/${header.bucketId}/${header.objectId}/${header.objectGeneration}/${header.eventTime}"
- choice:
precondition: true
when:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.citrus.it.yaml
index f8ae399f0..600284f12 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.citrus.it.yaml
@@ -107,3 +107,9 @@ actions:
verify:
integration: "aws-s3-ceph-event-based-source-get-object"
logMessage: "Read reports/a&b=c.txt: Content of the second file"
+ # The file comes with the ceph-event-id header of its event
+ - camel:
+ cli:
+ verify:
+ integration: "aws-s3-ceph-event-based-source-get-object"
+ logMessage: "Event 2"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.yaml
index e81b30e24..c304b73c1 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.yaml
@@ -33,3 +33,5 @@
type: String
- log:
message: "Read ${header.CamelAwsS3ProducedKey}: ${body}"
+ - log:
+ message: "Event ${header[ceph-event-id]}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-duplicates.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-duplicates.citrus.it.yaml
new file mode 100644
index 000000000..694901716
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-duplicates.citrus.it.yaml
@@ -0,0 +1,141 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: aws-s3-event-based-source-duplicates-test
+description: 'aws-s3-event-based-source gives the copies of an S3 event the
same aws-s3-event-id, so an idempotentConsumer step after it processes each
event once'
+variables:
+ - name: "aws.sqs.queueName"
+ value: "queue-s3-dup-events"
+actions:
+ # Create AWS infrastructure (Floci container)
+ - testcontainers:
+ start:
+ localstack:
+ services:
+ - "SQS"
+ options:
+ queues: '${aws.sqs.queueName}'
+ sqsClientName: "sqsDupEventsClient"
+ - waitFor:
+ http:
+ url: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}"
+
+ # Create Camel JBang integration
+ - camel:
+ cli:
+ run:
+ integration:
+ file: "aws/s3/aws-s3-event-based-source-duplicates.yaml"
+ systemProperties:
+ properties:
+ - name: "aws.sqs.queueName"
+ value: "${aws.sqs.queueName}"
+ - name: "aws.uriEndpointOverride"
+ value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}"
+ - name: "aws.secretKey"
+ value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}"
+ - name: "aws.accessKey"
+ value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}"
+ - name: "aws.region"
+ value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_REGION}"
+ - name: "http.sink.url"
+ value: "http://localhost:${aws.sink.server.port}"
+
+ # An event with a sequencer: its ID is made of the event type, the bucket,
the key and the sequencer
+ - send:
+ endpoint:
camel:aws2-sqs://${aws.sqs.queueName}?amazonSQSClient=#sqsDupEventsClient
+ message:
+ body:
+ data:
'{"version":"0","id":"e-1","source":"aws.s3","detail-type":"Object
Created","detail":{"bucket":{"name":"bucket-dup-events"},"object":{"key":"in/order
1.csv","sequencer":"0055AED6DCD90281E5"},"reason":"PutObject"}}'
+ - http:
+ server: "awsSinkServer"
+ receiveRequest:
+ POST:
+ path: "/event"
+ headers:
+ - name: "X-Event-Id"
+ value: 'Object Created/bucket-dup-events/in/order
1.csv/0055AED6DCD90281E5'
+ type: "plaintext"
+ body:
+ data: "@contains('\"id\":\"e-1\"')@"
+ - http:
+ server: "awsSinkServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # A copy of it in another SQS message, with another EventBridge id, is
skipped. An event without a
+ # sequencer has the EventBridge id as its ID, and a copy of it is skipped
too.
+ - send:
+ endpoint:
camel:aws2-sqs://${aws.sqs.queueName}?amazonSQSClient=#sqsDupEventsClient
+ message:
+ body:
+ data:
'{"version":"0","id":"e-2","source":"aws.s3","detail-type":"Object
Created","detail":{"bucket":{"name":"bucket-dup-events"},"object":{"key":"in/order
1.csv","sequencer":"0055AED6DCD90281E5"},"reason":"PutObject"}}'
+ - send:
+ endpoint:
camel:aws2-sqs://${aws.sqs.queueName}?amazonSQSClient=#sqsDupEventsClient
+ message:
+ body:
+ data:
'{"version":"0","id":"e-3","source":"aws.s3","detail-type":"Object Tags
Added","detail":{"bucket":{"name":"bucket-dup-events"},"object":{"key":"in/order
1.csv"}}}'
+ - http:
+ server: "awsSinkServer"
+ receiveRequest:
+ POST:
+ path: "/event"
+ headers:
+ - name: "X-Event-Id"
+ value: 'e-3'
+ type: "plaintext"
+ body:
+ data: "@contains('\"id\":\"e-3\"')@"
+ - http:
+ server: "awsSinkServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ - send:
+ endpoint:
camel:aws2-sqs://${aws.sqs.queueName}?amazonSQSClient=#sqsDupEventsClient
+ message:
+ body:
+ data:
'{"version":"0","id":"e-3","source":"aws.s3","detail-type":"Object Tags
Added","detail":{"bucket":{"name":"bucket-dup-events"},"object":{"key":"in/order
1.csv"}}}'
+ - send:
+ endpoint:
camel:aws2-sqs://${aws.sqs.queueName}?amazonSQSClient=#sqsDupEventsClient
+ message:
+ body:
+ data:
'{"version":"0","id":"e-4","source":"aws.s3","detail-type":"Object
Deleted","detail":{"bucket":{"name":"bucket-dup-events"},"object":{"key":"in/order
1.csv","sequencer":"0055AED6DCD90281F0"},"reason":"DeleteObject"}}'
+ - http:
+ server: "awsSinkServer"
+ receiveRequest:
+ POST:
+ path: "/event"
+ headers:
+ - name: "X-Event-Id"
+ value: 'Object Deleted/bucket-dup-events/in/order
1.csv/0055AED6DCD90281F0'
+ type: "plaintext"
+ body:
+ data: "@contains('\"id\":\"e-4\"')@"
+ - http:
+ server: "awsSinkServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-duplicates.yaml
similarity index 70%
copy from
tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.yaml
copy to
tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-duplicates.yaml
index ec2fffa8a..a126a659d 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-duplicates.yaml
@@ -15,6 +15,11 @@
# limitations under the License.
# ---------------------------------------------------------------------------
+# Each event once: the copies of an event have the same aws-s3-event-id
+- beans:
+ - name: eventRepository
+ type:
org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository
+
- route:
from:
uri: "kamelet:aws-s3-event-based-source"
@@ -25,9 +30,13 @@
accessKey: "{{aws.accessKey}}"
secretKey: "{{aws.secretKey}}"
region: "{{aws.region}}"
- getObject: "true"
steps:
- - convertBodyTo:
- type: String
- - log:
- message: "Read ${header.CamelAwsS3ProducedKey}: ${body}"
+ - idempotentConsumer:
+ simple: "${header[aws-s3-event-id]}"
+ idempotentRepository: "eventRepository"
+ steps:
+ - setHeader:
+ name: X-Event-Id
+ simple: "${header[aws-s3-event-id]}"
+ - to:
+ uri: "{{http.sink.url}}/event"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.citrus.it.yaml
index 34663188b..aa88510b8 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.citrus.it.yaml
@@ -85,7 +85,7 @@ actions:
endpoint:
camel:aws2-sqs://${aws.sqs.queueName}?amazonSQSClient=#sqsEventsClient
message:
body:
- data: '{"version":"0","source":"aws.s3","detail-type":"Object
Created","detail":{"bucket":{"name":"${aws.s3.bucketNameOrArn}"},"object":{"key":"dir/my
file+x=1.txt"},"reason":"PutObject"}}'
+ data:
'{"version":"0","id":"e-1","source":"aws.s3","detail-type":"Object
Created","detail":{"bucket":{"name":"${aws.s3.bucketNameOrArn}"},"object":{"key":"dir/my
file+x=1.txt","sequencer":"0055AED6DCD90281E5"},"reason":"PutObject"}}'
- send:
endpoint:
camel:aws2-sqs://${aws.sqs.queueName}?amazonSQSClient=#sqsEventsClient
message:
@@ -103,3 +103,9 @@ actions:
verify:
integration: "aws-s3-event-based-source-get-object"
logMessage: "Read reports/a&b=c.txt: Content of the second file"
+ # The file comes with the aws-s3-event-id header of its event
+ - camel:
+ cli:
+ verify:
+ integration: "aws-s3-event-based-source-get-object"
+ logMessage: "Event Object Created/${aws.s3.bucketNameOrArn}/dir/my
file+x=1.txt/0055AED6DCD90281E5"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.yaml
index ec2fffa8a..19f1534c4 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-event-based-source-get-object.yaml
@@ -31,3 +31,5 @@
type: String
- log:
message: "Read ${header.CamelAwsS3ProducedKey}: ${body}"
+ - log:
+ message: "Event ${header[aws-s3-event-id]}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.citrus.it.yaml
index c379f2eea..73198c1c3 100644
---
a/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.citrus.it.yaml
@@ -114,6 +114,8 @@ actions:
value: 'text/plain'
- name: "X-Blob-Name"
value: 'name='
+ - name: "X-Event-Id"
+ value:
'Microsoft.Storage.BlobCreated//blobServices/default/containers/orders/blobs/order-1.txt/00000000000000000000000000015508000000000005101c'
body:
data: 'Hello Azure Blob Event'
- http:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.yaml
index a4607e60e..2f107a0f8 100644
---
a/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/azure/azure-storage-blob-event-based-source-route.yaml
@@ -23,7 +23,7 @@
steps:
# the event that Event Grid sends to the queue when the blob
orders/order-1.txt is created
- setBody:
- constant:
'{"topic":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/kamelets/providers/Microsoft.Storage/storageAccounts/devstoreaccount1","subject":"/blobServices/default/containers/orders/blobs/order-1.txt","eventType":"Microsoft.Storage.BlobCreated","id":"831e1650-001e-001b-66ab-eeb76e069631","data":{"api":"PutBlob","contentType":"text/plain","contentLength":22,"blobType":"BlockBlob","url":"https://devstoreaccount1.blob.core.windows.net/orders/order-1.t
[...]
+ constant:
'{"topic":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/kamelets/providers/Microsoft.Storage/storageAccounts/devstoreaccount1","subject":"/blobServices/default/containers/orders/blobs/order-1.txt","eventType":"Microsoft.Storage.BlobCreated","id":"831e1650-001e-001b-66ab-eeb76e069631","data":{"api":"PutBlob","contentType":"text/plain","contentLength":22,"blobType":"BlockBlob","url":"https://devstoreaccount1.blob.core.windows.net/orders/order-1.t
[...]
- to:
uri: "azure-servicebus:blob-events"
parameters:
@@ -53,6 +53,9 @@
- setHeader:
name: X-Blob-Name
simple: "name=${header.CamelAzureStorageBlobBlobName}"
+ - setHeader:
+ name: X-Event-Id
+ simple: "${header[azure-storage-blob-event-id]}"
# the body as text, for the HTTP call
- convertBodyTo:
type: "java.lang.String"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.citrus.it.yaml
index 13bac569a..42a66ed16 100644
---
a/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.citrus.it.yaml
@@ -153,6 +153,8 @@ actions:
value: 'in/order-1.txt'
- name: "X-Bucket-Id"
value: 'kamelets-orders'
+ - name: "X-Event-Id"
+ value:
"@matches('OBJECT_FINALIZE/kamelets-orders/in/order-1.txt/[0-9]+/1')@"
- name: "X-Object-Content-Type"
value: 'text/plain'
- name: "X-Object-Name"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.yaml
index 955629b0d..86ab71daa 100644
---
a/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/google/google-storage-event-based-source-route.yaml
@@ -41,6 +41,9 @@
- setHeader:
name: X-Bucket-Id
simple: "${header.bucketId}"
+ - setHeader:
+ name: X-Event-Id
+ simple: "${header[google-storage-event-id]}"
- setHeader:
name: X-Object-Content-Type
simple: "${header.CamelGoogleCloudStorageContentType}"