saravanakumar1987 opened a new pull request, #30193: URL: https://github.com/apache/camel/pull/30193
# Description Part of [CAMEL-23832](https://issues.apache.org/jira/browse/CAMEL-23832). This pull request covers `camel-alibaba-eventbridge` (scheme `alibaba-eventbridge`). It does not complete the ticket, so please keep the ticket open. This is the fifth of the eight Alibaba components, after `camel-alibaba-ots` (#29991), `camel-alibaba-fc` (#30004), `camel-alibaba-kms` (#30139, still open) and `camel-alibaba-sms` (#30144, still open). With the eventbridge names, the texts of `operation`, `accessKey`, `secretKey` and `serviceKeys` are the ots and fc texts merged in #29991 and #30004. The `eventBridgeClient` text is the merged fc text with the class of eventbridge, except that its third sentence is the merged ots sentence with EventBridgeClient in place of SyncClient. The request ID text is the merged ots text with EventBridge, with "The producer sets it, unless the exchange fails." of the merged fc texts as its second sentence. The first and third sentences of `region` and of `endpoint` are those of the merged fc texts. In the texts of the other options and headers, the sentences on the header and the exchange property that replace a value are those of the merged ots and fc texts (the ots header text got its sent ence on the exchange property in #30112). All other sentences are new for eventbridge: the second sentences of `region` and `endpoint`, the first sentence of each other input, "The value must be a URI.", the sentences on the keys of a Map body, the required sentences, the last sentence of `eventSubject`, and the other sentences of the three validate options, of `allowedEventSources` and of `eventSourceCacheTtl`. The required sentences are "One of the three is required." of the merged fc texts with the body kinds, and the last sentences of `eventSubject` and `allowedEventSources` have the form of the last sentence of the merged fc qualifier text. Each input header text repeats the sentences of its option, with the sentences of the merged ots and fc header texts in place of the two sentences on the header and the exchange property, and without the other sentences that name the three. Its sentence on a Map key says "replaces this header" in place of "replaces the three", and the `CamelAlibabaEventBridgeAllowedEventSources` t ext refers to the option for a String in place of the sentences on the written forms. Only description texts change: 16 endpoint options and 10 headers. No option or header is added, removed or renamed, and no default value, label, type or enum value changes. The component description stays as it is. The row of `camel-alibaba-eventbridge` in `tasks/component-descriptions.md` is marked done. The new texts are in the `description` attribute of the annotations (`@UriPath` and `@UriParam` on the endpoint options, `@Metadata` on the header constants). The old texts were already in that attribute and no setter had Javadoc, so no Javadoc is removed. The names were checked against the sources of `com.aliyun:eventbridge-client` 1.3.14 (the EventBridge SDK below), the version set by `aliyun-eventbridge-client-version` in `parent/pom.xml`. Its client `com.aliyun.eventbridge.EventBridgeClient` does not extend the tea-openapi client: it runs on `com.aliyun:tea` 1.4.3 (`tea-version`) directly, with `com.aliyun:tea-util` 0.2.28 (`tea-util-version`), `com.aliyun:eventbridge-util` 0.0.4 and `com.aliyun:credentials-java` 0.2.5. The sources of eventbridge-client and tea were read, and eventbridge-util, tea-util and credentials-java, which have no sources jar, and the binary jar of eventbridge-client were read with javap. The runs named below used only 127.0.0.1, and all but the run of `JavadocHelper.sanitizeDescription` used the classes of this module and of camel-alibaba-common, compiled with javac from the sources before this change and run on the test classpath of the module. No request was sent to Alibaba Cloud and no page of the Ali baba Cloud documentation was read, so the terms come from the SDK, the module and the earlier texts. In the texts, the bare name of another input, such as eventBusName, stands for the value that the producer resolves from its header, its exchange property and its option, as the cxf texts name other options. | Text | Problem in the current text | Checked against | |---|---|---| | `operation` (endpoint path option) | It does not say that the CamelAlibabaEventBridgeOperation header, and after it an exchange property of the same name, replace the option. | `AlibabaEventBridgeComponent.createEndpoint` and the `AlibabaEventBridgeEndpoint` constructor (the path of the endpoint URI), `AlibabaEventBridgeProducer.process` (a blank operation fails with `Operation name not found`, any other value than putEvents with `Unsupported operation:` and the value), `AlibabaEventBridgeUtils.createClientConfigurations`, camel-alibaba-common `OpenApiClientSupport.resolveString` (the header, if it is blank the exchange property of the same name, if that is blank the option), `AlibabaEventBridgeProperties` (the name CamelAlibabaEventBridgeOperation, which `AlibabaEventBridgeHeaders` does not declare). In a run on the URI path foo, the header with the value putEvents made the producer send the request. In the same run, the header or the exchange property with the value foo failed with `Unsupported operation: foo`, and a blank header fell through to the path. The ots and fc text word for word, with the header name of eventbridge. The tests use only the path putEvents. | | `region` (endpoint option) | It does not say that the value is a region ID, what the producer does with it, nor that it is not used when eventBridgeClient is set or autowired. | `AlibabaEventBridgeUtils.createClient` (region and endpoint both blank fail with `Region or endpoint is required`, and the region goes into the SDK configuration only when it is not blank; no other Camel code reads the option), `AlibabaEventBridgeEndpoint.initClient` and `DefaultEndpoint.doInit` (as `eventBridgeClient`); SDK `EventBridgeClient` (the constructor keeps the region, and `doRequest`, which sends every request of the client, adds the HTTP header x-eventbridge-regionId when the region is set; javap shows no other read of it, and the host of each request is the endpoint, so the region does not change it). In a run against a local server on 127.0.0.1 with the region cn-hangzhou, the putEvents, listEventBuses and listRules requests all carried x-eventbridge-regionId: cn-hangzhou. In the same run, without a region the header was missing. In another run, a region without an endpoint failed at the first message with `'endpoint' can not be unset`. The example: the doc page and `testconfiguration.properties` (cn-hangzhou). The first and third sentences are those of the merged fc text. The second sentence is new, because the SDK never builds an endpoint from the region: it says what the producer does with the value, and "HTTP header" sets that header apart from the Camel headers of the other texts. No test reads the option. | | `endpoint` (endpoint option) | It calls the value a URL, although the SDK rejects a value with http:// or https://, and it speaks of a region based client initialization, which does not exist: without the endpoint, the client cannot be created. | `AlibabaEventBridgeUtils.createClient` (region or endpoint is required, and the endpoint goes into the SDK configuration only when it is not blank; Camel checks nothing else); SDK `EventBridgeClient` (an empty endpoint fails with `'endpoint' can not be unset`, a value that starts with http fails with `'endpoint' shouldn't start with 'http' or 'https'`, and the endpoint is the host header of each request). In a run against a local server on 127.0.0.1, the endpoint option without a region was enough. In the same run, the region alone failed with `'endpoint' can not be unset`, neither of the two with `Region or endpoint is required`, and http:// and https:// with the second SDK message above. The first and third sentences are those of the merged fc text, and the second sentence is new. No test reads the option. | | `accessKey` (endpoint option) | It does not use the Alibaba Cloud term AccessKey ID, and it does not say how the option relates to serviceKeys and eventBridgeClient. | `AlibabaEventBridgeUtils.createClient`, camel-alibaba-common `OpenApiClientSupport.resolveAccessKey` (the option if it is not blank, else the accessKey of serviceKeys, else `Authentication parameter 'access key (AK)' not found`), `AlibabaEventBridgeEndpoint.initClient` (a set or autowired client is returned before any key is read), `DefaultEndpoint.doInit`; SDK `EventBridgeClient` (the AccessKey ID is sent in the authorization header, and the AccessKey secret signs the request). In a run against a local server on 127.0.0.1, the request carried the AccessKey ID of the option, else that of serviceKeys, and the option won over serviceKeys. In the same run, without both, the first message failed with the message above. The ots and fc text word for word, with EventBridge and eventBridgeClient. The requests include list EventBuses and listRules of the validate options. | | `secretKey` (endpoint option) | It does not use the Alibaba Cloud term AccessKey secret, and it does not say how the option relates to serviceKeys and eventBridgeClient. | As `accessKey`, with `OpenApiClientSupport.resolveSecretKey` and the message `Authentication parameter 'secret key (SK)' not found`. Each key falls back on its own: in a run, accessKey without secretKey failed with that message. The ots and fc text word for word, with EventBridge and eventBridgeClient. | | `serviceKeys` (endpoint option) | It does not say what the object holds, nor when its values are used. | camel-alibaba-common `ServiceKeys` (the properties accessKey and secretKey), `OpenApiClientSupport.resolveAccessKey` and `resolveSecretKey` (each key falls back to serviceKeys on its own), `AlibabaEventBridgeUtils.createClient`, `AlibabaEventBridgeEndpoint.initClient`, `DefaultEndpoint.doInit`. In a run against a local server on 127.0.0.1, `serviceKeys=#keys` alone was enough, and the request carried its accessKey. The ots and fc text word for word, with eventBridgeClient. | | `eventBusName` (endpoint option) | "Default" does not say what replaces the value (the header, an exchange property of the same name and the key eventBusName of a Map body), for which bodies it is used, nor when it is required. | `AlibabaEventBridgeUtils.createClientConfigurations` and `OpenApiClientSupport.resolveString` with the name CamelAlibabaEventBridgeEventBusName, as `operation`; a List body shares this one value for all its items. JSON text body (`AlibabaEventBridgeUtils.toCloudEvent`, for a String or a body that converts to bytes, such as bytes, a stream or a file): the event bus comes from the three only, and a blank event bus name, event source or event type fails with `Event source, type and event bus name are required when the body is JSON text`. Map body (`MapCloudEventValidator.validateAndBuild`): the key eventBusName, trimmed, if it is not blank, else the three, else `Event bus name is required`. For both, the event gets the name as the extension aliyuneventbusn ame. A CloudEvent body is sent as it is, and the producer writes none of the three into it. In a run, the header, the exchange property and the option were set alone and together, a blank header fell through to the next value, the Map key won over the header and the option, and a missing name failed for a JSON text and a Map body with the messages above. In a run against a local server on 127.0.0.1, the request body carried `"aliyuneventbusname":"bus1"`. The sentences on the header and the exchange property are those of the merged ots and fc option texts, and the others are new. `PutEventsTest` uses the Map key eventBusName and the option, and no test sets the header or the exchange property. | | `eventSource` (endpoint option) | "Default" does not say what replaces the value, for which bodies it is used, when it is required, nor that it must be a URI. | As `eventBusName`, with the name CamelAlibabaEventBridgeEventSource. JSON text body: required as for `eventBusName`, and the value goes through `URI.create` to the SDK `EventBuilder.withSource`, so a value that is not a URI fails with the message of java.net.URI. Map body: the key eventSource, then the key source, else the three, else `Event 'source' cannot be empty`, and then `Event 'source' is not a valid URI:` and the value. In the run of `eventBusName`, the same combinations held for the event source, eventSource won over source, and a value that is not a URI failed on both paths, on the JSON text path for example with `Illegal character in path at index 1: a b`. The sentences on the header and the exchange property are those of the merged ots and fc option texts, and the others are new. `PutEventsTest` and `MapCloud EventValidationTest` (testValidateFailsWhenSourceMissing). | | `eventType` (endpoint option) | "Default" does not say what replaces the value, for which bodies it is used, nor when it is required. | As `eventBusName`, with the name CamelAlibabaEventBridgeEventType. JSON text body: required as for `eventBusName`. Map body: the key eventType, then the key type, else the three, else `Event 'type' cannot be empty`. In the run of `eventBusName`, the same combinations held for the event type, and eventType won over type. The sentences on the header and the exchange property are those of the merged ots and fc option texts, and the others are new. `PutEventsTest` and `MapCloudEventValidationTest` (testValidateFailsWhenTypeMissing). | | `eventSubject` (endpoint option) | "Default" does not say what replaces the value, for which bodies it is used, nor what happens when it is not set. | As `eventBusName`, with the name CamelAlibabaEventBridgeEventSubject. JSON text body: added only when the value is not blank. Map body: the key eventSubject, then the key subject, else the three, added only when not blank. The producer does not read the subject of a CloudEvent body. In the run of `eventBusName`, the same combinations held for the event subject, eventSubject won over subject, and no subject was in the event when none was set. The sentences on the header and the exchange property are those of the merged ots and fc option texts, and the others are new. The last sentence has the form of the last sentence of the merged fc qualifier text, with the Map key as a fourth source and "to the event". `PutEventsTest` (testPutEventsWithListOfMapsAndSubjectAndEntryList). | | `validateEventSource` (endpoint option) | It leaves out the check of the event source against the rules of the event bus, and it ties the check against allowedEventSources to this option, although the producer checks allowedEventSources whenever it is set. What this option adds to allowedEventSources is that each event source that it allows must match a rule. | `AlibabaEventBridgeUtils.createClientConfigurations` and `OpenApiClientSupport.resolveBoolean` with the name CamelAlibabaEventBridgeValidateEventSource (the header as a Boolean, if that is null the exchange property, if that is null the option; a String converts only if it is true or false, in any case). `MapCloudEventValidator.validateBusSourceAndType`, for each event of every body kind, when this option or validateEventType is true: `EventSourceCache.validateAndUpdateCache` calls listEventBuses with the name of the event bus as NamePrefix, which must return a bus of exactly that name, else `Event bus '{bus}' does not ex ist in Alibaba Cloud EventBridge`, and then listRules for the event bus. With this option, the event source must match a rule of the event bus, else `Event source '{source}' is not registered on event bus '{bus}' in Alibaba Cloud EventBridge`. With allowedEventSources, each event source that the list allows for the event bus must match a rule, else `Event source '{source}' is not registered in Alibaba Cloud rules for event bus '{bus}'. Known sources: ...`. The result is cached per event bus name (see `eventSourceCacheTtl`). In a run against a local server on 127.0.0.1, the first message called listEventBuses and listRules once, and the second neither. In the same run, a bus whose name only started with the wanted name, a source that no rule matched, a bus without rules, and an error of listEventBuses or listRules each failed the exchange before putEvents. In the same run, a prefix rule and a rule without a source filter matched, and with allowedEventSources, a listed source that no rule matched failed the exchange. The first three sentences are new, the first in the form "Whether to ..." of the cxf texts, and the others are those of the merged ots and fc option texts. `MapCloudEventValidationTest` (testValidatedCacheWorkflowSuccess, testCloudApiFailureFailsClosedOnBusCheck, testCloudApiFailureFailsClosedOnRulesCheck, testPrefixFilterPatternMatching), with a mock client. | | `validateEventType` (endpoint option) | It does not say that the option also checks that the event bus exists, which calls the producer makes, that it caches their result, nor what it adds to allowedEventSources. | `OpenApiClientSupport.resolveBoolean` with the name CamelAlibabaEventBridgeValidateEventType, as `validateEventSource`. `MapCloudEventValidator.validateBusSourceAndType`: the steps of `validateEventSource` up to the existence of the event bus, then the event type must match a rule for the event source, else `Event type '{type}' is not valid for event source '{source}' on event bus '{bus}' in Alibaba Cloud EventBridge`. With allowedEventSources, each event type that the list allows for an event source of the event bus must match a rule for that source, else `Event type '{type}' is not registered in Alibaba Cloud rules for source '{source}' on bus '{bus}'. Allowed in Cloud: ...`. In a run against a local server on 127.0.0.1, validateEventType alone checked the event bus , a missing bus failed with the message of `validateEventSource`, and the producer called listRules. In the same run, a type matched exactly and by a prefix rule passed, and a type that no rule matched failed. In the same run, with allowedEventSources, a listed type that no rule matched failed the exchange. The sentences of `validateEventSource`, with "and event type" in the first and "each event type" in the third. `MapCloudEventValidationTest` (testValidatedCacheWorkflowFailsWhenTypeNotOnCloud). | | `validateEventSpec` (endpoint option) | It does not say which constraints the producer checks: only the keys specversion and id of a Map body. | `OpenApiClientSupport.resolveBoolean` with the name CamelAlibabaEventBridgeValidateEventSpec, as `validateEventSource`. `MapCloudEventValidator`: only `validateAndBuild`, the path of a Map body, calls `validateSpecConstraints`. A key specversion, trimmed, must be 1.0, else `Invalid CloudEvent specversion: '{value}'. Only '1.0' is supported.`, and a key id must not be blank, else `Event 'id' cannot be blank when provided`. In a run, specversion 0.3 failed with true and passed with false, `" 1.0 "` passed, and an id `""` or `" "` failed with true. In the same run, a JSON text body or a CloudEvent body with such values passed with true. The first two sentences are new, the first in the form "Whether to ..." of the cxf texts, and the others are those of the merged ots and fc option texts. `MapCloudEventValidationTest` (testValidateFailsWhe nInvalidSpecversion, testValidateEventSpecFalseAllowsNonStandardValues). | | `allowedEventSources` (endpoint option) | The build drops the `>` of each `->`, so the catalog shows bus[src - type1,type2]. The text does not say what the producer does with the value, nor to which event bus a list without brackets applies, and the option, a String, cannot take the Map or List objects that it names. | `AlibabaEventBridgeUtils.resolveAllowedEventBuses`: the header, then the exchange property, then the option, parsed for each exchange. A String is read as JSON when it starts with `{`, else as the bus blocks name[...], else as one list for the default event bus, and `parseSourcesBlock` splits a list on `;` into event sources, each with its event types after `->` or `=`, separated by commas. The default event bus is the event bus name that the producer resolves from the three of `eventBusName`, else the key `*`, which applies to an event bus that has no entry of its own. The checks for each event (`MapCloudEventValidator`): the event bus must have an entry or the l ist a `*` entry, else `Event bus '{bus}' is not in the allowed event buses list: ...`; the event source must be listed for the event bus, else `Event source '{source}' is not in the allowed sources list for bus '{bus}'. Allowed: ...`; and the event type must be listed for the event source, where an event source without types allows every event type, else `Event type '{type}' is not allowed for event source '{source}' on bus '{bus}'. Allowed types: ...`. The option is a String: the configurer converts the value to java.lang.String. In a run, `allowedEventSources=#wlMap` stayed the literal String `#wlMap`. The same run covered the list with `->` and with `=`, blocks for two buses and for `*`, JSON with bus keys and flat JSON, a list without brackets with and without eventBusName, the header replacing the option, the exchange property alone, the messages above, and `RAW(busA[app.orders -> t1] \| busB[app.pay])` in the URI. In a run of `JavadocHelper.sanitizeDescription` of camel-toolin g-util, the current text came out with each `>` dropped, and the proposed text came out unchanged. The text writes `=` in place of `->`, because the code accepts both, the doc page names both, and `>` does not survive the build. It says that semicolons separate the event sources of one event bus, because a comma between two event sources makes the second a type of the first, and it shows the form without bus blocks, because two obvious guesses for that form parse without an error into something else. "for the exchange" sets the event bus name of the three apart from the key eventBusName of a Map body, which is a value of one event and is not used here. The sentences on the header and the exchange property are those of the merged ots and fc option texts, and the others are new. The last sentence has the form of the last sentence of the merged fc qualifier text. `MapCloudEventValidationTest` (testSingleBusDslWithColonsInSourceAndTypes, testMultiBusDslWithColonsInSourceAndTypes, testJs onConfigurationParsing) and `PutEventsTest` (testPutEventsWithEndpointValidatedDsl). | | `eventSourceCacheTtl` (endpoint option) | The cache holds the rules of the event bus too, not only its existence, and validateEventType uses it as well as validateEventSource. | `AlibabaEventBridgeUtils.createClientConfigurations` and `OpenApiClientSupport.resolveLong` with the name CamelAlibabaEventBridgeEventSourceCacheTtl (the header as a Long, if that is null the exchange property, if that is null the option). `MapCloudEventValidator`: the TTL of the message goes to the cache when validateEventSource or validateEventType is true. `EventSourceCache`: an entry per event bus name with the result of listEventBuses and listRules, stored only when the TTL is above 0, with times in milliseconds (`System.currentTimeMillis`). In a run against a local server on 127.0.0.1, with the default, the second message called neither listEventBuses nor listRules. In the same run, with 0 and with -1, each event made 3 listEventBuses and 2 listRules requests, and 4 and 3 with both flags. In the sa me run, validateEventType alone used the cache too, and the header 0 and 1000 replaced the option. The first three sentences are new: "Only used when ..." as in the merged fc region text, and "The time in milliseconds ..." and "Use 0 ..." in the form of the cxf continuationTimeout text ("The timeout in milliseconds ...", "Use 0 for no timeout."). The others are those of the merged ots and fc option texts. `MapCloudEventValidationTest` (testPerMessageCacheTtlHeaderOverride, which sets the TTL through `ClientConfigurations`, not through the header). | | `eventBridgeClient` (endpoint option) | It does not say what the option replaces, nor who creates the client and when. | `AlibabaEventBridgeEndpoint` (`initClient`, `setEventBridgeClient` and its flag, and `doStop`, which drops the reference to a client that the Camel endpoint created and closes nothing), `AlibabaEventBridgeProducer` (it keeps its own reference and calls `initClient` only while that reference is null, after the check of a blank operation), the generated `AlibabaEventBridgeEndpointConfigurer` (`getAutowiredNames`), `DefaultEndpoint.doInit` (an autowired option that is null gets the single bean of its type in the registry); SDK `EventBridgeClient`, which implements com.aliyun.eventbridge.EventBridge only (neither type has a close, shutdown or destroy method, so the sentences of the otsClient text about shutting down are left out). In a run with one EventBridgeClient bean in the registry and no reference, region, endpoint or keys in the URI, the Camel endpoint used that bean, and with region, endpoint and keys in the URI as well, it still used the bean. In the same run, with two beans nothing was autowired and the Camel endpoint created its own client, and starting the route created no client and sent nothing. The first, second and fourth sentences are those of the merged fc text with the class of eventbridge, and the third is the merged ots sentence with EventBridgeClient in place of SyncClient. All three test classes use a mock client: `PutEventsTest` and `PutEventsBodyTest` set `eventBridgeClient=#eventBridgeClient`, and `MapCloudEventValidationTest` passes the mock to `MapCloudEventValidator`, so creating the client and autowiring without the reference are not covered. | | `CamelAlibabaEventBridgeEventBusName` (header) | It says override without saying what is overridden, and a key of a Map body overrides the header itself. | As `eventBusName`. In the run of `eventBusName`, the header won over the exchange property and the option, and the Map key won over the header. The sentences on the option that the header replaces and on the exchange property are those of the merged ots and fc header texts. The first sentence is that of `eventBusName`, and the last is its sentence on the Map key with "replaces this header". No test sets the header. | | `CamelAlibabaEventBridgeEventSource` (header) | It says override without saying what is overridden, nor that the value must be a URI. | As `eventSource`. In the run of `eventBusName`, a header that is not a URI failed with the message of java.net.URI. The second sentence is that of `eventSource`. The rest as `CamelAlibabaEventBridgeEventBusName`. | | `CamelAlibabaEventBridgeEventType` (header) | It says override without saying what is overridden. | As `eventType`. The rest as `CamelAlibabaEventBridgeEventBusName`. | | `CamelAlibabaEventBridgeEventSubject` (header) | It says override without saying what is overridden. | As `eventSubject`. The rest as `CamelAlibabaEventBridgeEventBusName`. | | `CamelAlibabaEventBridgeValidateEventSource` (header) | It does not say what is checked, how, nor that the header replaces the validateEventSource option. | As `validateEventSource`. The sentences on the option that the header replaces and on the exchange property are those of the merged ots and fc header texts, and the others are those of `validateEventSource`. | | `CamelAlibabaEventBridgeValidateEventType` (header) | It does not say that the event bus is checked too, how, nor that the header replaces the validateEventType option. | As `validateEventType`. In a run, the header true or "true" made the producer call listEventBuses and listRules. The sentences on the option that the header replaces and on the exchange property are those of the merged ots and fc header texts, and the others are those of `validateEventType`. | | `CamelAlibabaEventBridgeValidateEventSpec` (header) | It does not say which constraints the producer checks, nor that the header replaces the validateEventSpec option. | As `validateEventSpec`. In a run, the header false let a specversion 0.3 pass on an endpoint with the option true, and the exchange property did the same when the header was not set. The sentences on the option that the header replaces and on the exchange property are those of the merged ots and fc header texts, and the others are those of `validateEventSpec`. | | `CamelAlibabaEventBridgeAllowedEventSources` (header) | It does not say what the producer does with the value, nor that the header replaces the allowedEventSources option. | As `allowedEventSources`, with the forms that `AlibabaEventBridgeUtils.resolveAllowedEventBuses` reads from the header and the exchange property: a Map (event bus names to Maps of event sources to event types, event sources to event types for the default event bus, or AllowedEventBus values), a Collection (Strings in the form of a list without brackets, AllowedEventSource or AllowedEventBus items) or a String, which is parsed as for the option. A run covered the header as a String, as a Map of event bus names to Maps of event sources to types, as a Map of event sources to types, and as a Collection of Strings and of AllowedEventSource objects, and the header replacing the option and winning over the exchange property. The second sentence is new, in the form "The value must be ..." of `eventSource`. The sente nces on the option that the header replaces and on the exchange property are those of the merged ots and fc header texts, and the first is that of `allowedEventSources`. `PutEventsTest` sets the header as a Map of an event bus name to an AllowedEventBus. | | `CamelAlibabaEventBridgeEventSourceCacheTtl` (header) | It does not say when the value is used, nor that the header replaces the eventSourceCacheTtl option. | As `eventSourceCacheTtl`. In a run against a local server on 127.0.0.1, the header 0 made each message call listEventBuses and listRules on an endpoint with the default TTL, and the header 1000 kept the entry on an endpoint with the option 0. The sentences on the option that the header replaces and on the exchange property are those of the merged ots and fc header texts, and the others are those of `eventSourceCacheTtl`. | | `CamelAlibabaEventBridgeRequestId` (header) | It does not say who sets the header, nor when. | `AlibabaEventBridgeProducer` (after putEvents returns, the RequestId of `PutEventsResponse`, when it is not blank); SDK `EventBridgeClient` (the client parses the body of every response, and a 4xx or 5xx response throws a com.aliyun.tea.TeaException whose message has the request ID of the error body; there is one attempt, because a new RuntimeOptions has autoretry false, and tea retries only when it is true). In a run against a local server on 127.0.0.1, a 200 response set the header. In the same run, a 200 response with FailedEntryCount 1 and an entry with an error code did not fail the exchange, and the header was set. In the same run, 400, 403, 429 and 500 responses failed the exchange after one request, and the header was not set. In the same run, a 200 response without RequestId set no header, and an earlier value stayed. The ots text with EventBridge, with "The producer sets it, unless the exchange fails." of the merged fc texts, because "when the operation succeeds" of ots does not hold for a 2xx response in which some events failed. `PutEventsTest` checks the header. | ## Found in the review, not changed here - No event without an id can be sent with the SDK client: the path of a JSON text body never sets an id, a Map body sets one only from its key id, and the SDK sets none, so `EventBridgeClient.putEventsWithOptions` fails with `Field id is required` before any request for every JSON text body and every Map body without that key. The doc page shows a JSON text body as its first example and says that an omitted id is generated, and the module tests use a mock client, which does not reach that check. - `AlibabaEventBridgeEndpoint.initClient` is not synchronized, as in `camel-alibaba-ots` before CAMEL-26971 and in `camel-alibaba-mns` and `camel-alibaba-oss` before CAMEL-27003. Not investigated again for this pull request. - `region` has `@Metadata(required = true)` and `endpoint` has none, but the SDK needs the endpoint and not the region: a region alone passes the check of Camel, `Region or endpoint is required`, and then fails at the first message with `'endpoint' can not be unset`, and the examples of the doc page set a region and no endpoint. Moving the flag is a metadata change, and the check is code. - `AlibabaEventBridgeHeaders` has no constant for `CamelAlibabaEventBridgeOperation`, which the producer reads. Only its subclass `AlibabaEventBridgeProperties` declares it, so the header is missing from the header list of the component JSON, the endpoint DSL and the doc page. - `AlibabaEventBridgeProperties` carries `@Metadata` with a text of its own on `OPERATION`, but the build reads the fields of the headers class and of its supertypes, and this class is a subclass, so the text is not used. - A String that is not a number, such as abc or the empty String, in the `CamelAlibabaEventBridgeEventSourceCacheTtl` header or exchange property fails every exchange with a TypeConversionException before any request, also with both validate flags false, and without falling back to the option. The option itself also takes a duration such as 5m. - An `allowedEventSources` option with invalid JSON, such as `{bad`, is accepted when the endpoint is created, and then every exchange without the header or the exchange property of the same name fails with `Invalid JSON format for allowedEventSources`. - The TTL that `doStart` passes to the `EventSourceCache` constructor is not used at publish time: the producer passes the TTL of each message, and only the unused overloads of the cache read that field. - A blank primary key of a Map body hides its secondary key: an eventSource `""` falls back to the three even when the key source has a value. The same holds for type and subject. - A String other than true or false in a Boolean header or exchange property counts as not set, while the same String in the option fails the creation of the endpoint (`Cannot convert the String value: yes to type: boolean`). - The hand-written part of the doc page contradicts the code in places: an omitted id is not generated, the examples without an endpoint fail when the client is created, validateEventSpec checks two keys of a Map body and not CloudEvents 1.0 compliance, and the allowedEventSources option takes no Map or List objects. It also says otherwise on when the metadata is stored, which happens before the checks of the event source and type, and on entryList, which is absent when the response has none. - A failed check of the event source or event type against the rules leaves the entry of the event bus cached, because the cache stores the result of listEventBuses and listRules before those checks. - With an eventSourceCacheTtl of 0 or less, each event makes up to 4 listEventBuses and 3 listRules requests with both flags, and 3 and 2 with one flag, because each check fetches again. - A byte[] value of the key eventData of a Map body is decoded as UTF-8 whatever the charset of the exchange, while a JSON text body given as bytes is read in that charset. - A String value of the key time of a Map body without an offset fails with a raw java.time.DateTimeException instead of the message `Event 'time' must be in RFC 3339 / ISO-8601 format`. - The body type texts, from CAMEL-24961 and CAMEL-26260, describe a JSON text body that the SDK rejects, name no exchange properties, and say that the Map has the entryList of the response, which is absent when the response has none, without the TraceId of each entry. Body type texts are not part of this pull request. - validateEventType merges the type filters of all rules of an event source into one filter, so a rule without a type filter stops matching every event type as soon as another rule of the same source has one: with the rules `{source: [s], type: [t1]}` and `{source: [s]}`, the event s with the type t2 fails, although the second rule matches it. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I have run `mvn clean install -Dquickly -DskipTests` from the root folder on commit 27efa340d2df and then `mvn install -DskipTests -nsu` in `components/camel-alibaba/camel-alibaba-eventbridge`, `catalog/camel-catalog` and `dsl/camel-endpointdsl`, and I have committed all auto-generated changes. # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. The descriptions and this text were drafted with Claude (Anthropic) and checked against the Camel source and the sources of `com.aliyun:eventbridge-client` 1.3.14. _Claude Code on behalf of saravanakumar1987_ 🤖 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]
