davsclaus opened a new pull request, #30748: URL: https://github.com/apache/camel/pull/30748
_Claude Code on behalf of davsclaus_ Fixes [CAMEL-27101](https://issues.apache.org/jira/browse/CAMEL-27101), a follow-up of CAMEL-26300 (#29216, aws2-sqs: the CloudEvent source is the queue name). ## What was wrong In CloudEvents, `source` is the context in which the event happened, and the source and the id together identify an event. Several `application-cloudevents` data type transformers built `CamelCloudEventSource` (`ce-source`) from a value of each message, so most events had a source of their own and the source never named the queue, container or subscription. The four named in the JIRA did this, and three of the "worth a look" ones did too (archive status of the file, partition key the sender sets). ## What changed Each transformer now builds the source from the place the message was consumed from, as `aws2-s3` (bucket), `aws2-sqs` (queue), `google-storage` (bucket) and `google-sheets-stream` (spreadsheet) do. The prefixes are kept, except for the two whose prefix named the partition key. | Transformer | Source before | Source now | |---|---|---| | `azure-storage-queue:application-cloudevents` | `azure.storage.queue.<message id>` | `azure.storage.queue.<queue name>` | | `azure-storage-blob:application-cloudevents` | `azure.storage.blob.<ETag>` | `azure.storage.blob.<container name>` | | `google-pubsub:application-cloudevents` | `google.pubsub.<ack id>` (synchronous pull only; the default asynchronous pull got no source) | `google.pubsub.<subscription name>` | | `google-calendar-stream:application-cloudevents` | `google.calendar.stream.<event id>` | `google.calendar.stream.<calendar id>` (`primary` by default) | | `azure-storage-datalake:application-cloudevents` | `azure.storage.datalake.<archive status>` | `azure.storage.datalake.<file system name>` | | `azure-servicebus:application-cloudevents` | `azure.servicebus.partition.<partition key>` | `azure.servicebus.<queue or topic name>` | | `aws2-kinesis:application-cloudevents` | `aws.kinesis.partition.key.<partition key>` | `aws.kinesis.stream.<stream name>` | The name comes from a new consumer header, not from the from endpoint of the exchange, for the reason given in #29216: the output data type of a Kamelet runs in the route that consumes from the Kamelet, which gets the headers of the consumer but has its own from endpoint. | Consumer | New header | |---|---| | `azure-storage-queue` | `CamelAzureStorageQueueConsumedQueueName` | | `azure-storage-blob` | `CamelAzureStorageBlobConsumedContainerName` | | `azure-storage-datalake` | `CamelAzureStorageDataLakeConsumedFileSystemName` | | `azure-servicebus` | `CamelAzureServiceBusTopicOrQueueName` | | `aws2-kinesis` | `CamelAwsKinesisStreamName` (polling and KCL consumer) | | `google-pubsub` | `CamelGooglePubsubSubscriptionName` (synchronous and asynchronous pull) | | `google-calendar-stream` | `CamelGoogleCalendarCalendarId` | The three Azure Storage consumers get a `Consumed...` header instead of setting the existing `CamelAzureStorageQueueName`, `CamelAzureStorageBlobBlobContainerName` and `CamelAzureStorageDataLakeFileSystemName` headers: those override the queue, container or file system of a producer of the same component, so a route from queue A to queue B would send back to A. The route tests check that the consumer leaves those headers unset. A message without the new header gets no source from the transformer, as with `aws2-sqs`. The CloudEvent id is unchanged: it is still the exchange id, which is per message, so source + id identify each event. The subjects are unchanged (pop receipt, blob name, message id, event type, ETag, message id, shard id). ## Not changed - `google-mail-stream:application-cloudevents` keeps the sender address as the source. The context would be the mailbox, but the consumer only knows the user id it reads with (`me` by default), so no name of the mailbox is available without an extra API call. - `azure-eventhubs:application-cloudevents` (partition id) was not in the JIRA. The partition id is not a value of each message, but the event hub name would be the better context; left for a separate change if wanted. - Pub/Sub: the source is the subscription, the only name the consumer has (the `destinationName` of the endpoint), not the topic and not the full `projects/<project>/subscriptions/<name>` path. ## Upgrade guide New 4.24 entry next to the aws2-sqs one: the source before and after for each transformer, the new headers, why the Azure Storage consumers do not set the producer headers, and that a route relying on the old source can set `CamelCloudEventSource` after the transformer. ## Kamelets The Kamelets that document `CamelCloudEventSource` for these data types need the same change in their descriptions: `azure-storage-queue-source` ("the Message Id"), `azure-storage-blob-source` ("the E Tag"), `azure-storage-datalake-source` ("the Archive Status") and `google-calendar-source` ("the Calendar Event Id"). `google-pubsub-source`, `aws-kinesis-source` and `azure-servicebus-source` do not use the CloudEvent data type. This will be handled in camel-kamelets. ## Docs and generated files The component docs do not describe the CloudEvent source. The new headers are in the regenerated component JSON files, their catalog copies and the endpoint DSL header builders. ## Tests - Transformer unit tests per component: two messages from the same queue, container, file system, queue or topic, stream, subscription or calendar get the same source, and a message with only the old per-message header gets none. - Route tests for azure-storage-queue, azure-storage-blob, azure-storage-datalake and google-pubsub (synchronous pull, plus the asynchronous `CamelMessageReceiver`): mocked clients, the consumer hands the exchange over `seda` to a second route that runs the transformer, as the sink of a Kamelet does. - `KinesisConsumerStreamNameTest`: both the polling and the KCL consumer set the stream name. `GoogleCalendarStreamCloudEventDataTypeTransformerTest` checks the header from the endpoint, with an explicit calendar and the `primary` default. `ServiceBusConsumerTest` expects the new header. Revert check: with `src/main` reverted (new constants kept so the tests compile), 27 of the new or changed tests fail, each on its assertion (the old source, or the missing consumer header). Module unit tests (`mvn test` in each module), 0 failures: camel-azure-storage-queue 19, camel-azure-storage-blob 93, camel-azure-storage-datalake 40, camel-azure-servicebus 1083, camel-aws2-kinesis 1078, camel-google-pubsub 1058, camel-google-calendar 23 (the large counts include the 1000 seeds of each DST test). Integration tests that need Azure, GCP or LocalStack were not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
