saravanakumar1987 opened a new pull request, #30144:
URL: https://github.com/apache/camel/pull/30144

   # Description
   
   Part of [CAMEL-23832](https://issues.apache.org/jira/browse/CAMEL-23832). 
This pull request covers `camel-alibaba-sms` (scheme `alibaba-sms`). It does 
not complete the ticket, so please keep the ticket open.
   
   This is the fourth of the eight Alibaba components, after 
`camel-alibaba-ots` (#29991), `camel-alibaba-fc` (#30004) and 
`camel-alibaba-kms` (#30139, still open). The texts of `operation`, 
`accessKey`, `secretKey` and `serviceKeys` are the ots and fc texts merged in 
#29991 and #30004, and the texts of `endpoint` and `smsClient` are the merged 
fc texts, each with the sms names. The `region` text is the merged fc text with 
the sms names, except that its second sentence says "to determine the endpoint" 
in place of "to build the endpoint", because the SMS SDK takes the host from 
its endpoint map and builds no host name from the region. The sentences on the 
header and the exchange property that replace an option are those of the merged 
ots and fc texts (the ots header text got its sentence on the exchange property 
in #30112), and "One of the three is required." and "If none of the three is 
set, the producer adds no ... to the request." are those of the merged fc 
texts. The request ID te
 xt is the merged ots text with Short Message Service, with "The producer sets 
it, unless the exchange fails." of the merged fc texts as its second sentence.
   
   Only description texts change: 12 endpoint options and 6 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-sms` 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:dysmsapi20170525` 
4.6.0 (the SMS SDK below), the version set by `aliyun-dysmsapi-version` in 
`parent/pom.xml`, which is the SDK for Java of the Short Message Service API 
version 2017-05-25. Its client extends the client of `com.aliyun:tea-openapi` 
0.3.20 (`tea-openapi-version`) and runs on `com.aliyun:tea` 1.4.3 
(`tea-version`) and `com.aliyun:tea-util` 0.2.28 (`tea-util-version`). For a 
region that is not in its endpoint map, it takes the host from 
`com.aliyun:endpoint-util` 0.0.8, which the SMS SDK declares. The sources of 
tea-openapi and tea were read too, and tea-util and endpoint-util, which have 
no sources jar, were read with javap. The runs named below used only 127.0.0.1: 
the classes of this module and of camel-alibaba-common, compiled from the 
sources before this change, with the SDK jars above and a local server. Unless 
a row says that the Camel endpoint created the client, a run used a client set 
to the protocol 
 HTTP and to the local server. The probes of the SDK alone ran in the same way. 
No request was sent to Alibaba Cloud and no page of the Alibaba Cloud 
documentation was read, so the terms come from the SDK Javadoc (Short Message 
Service, SMS message, approved, external transaction ID) and from the names the 
component already uses (phone numbers, sign name, template code, template 
parameters). The SDK Javadoc writes signature name, but the component writes 
sign name in its display name, its error message and its doc page, so the texts 
keep sign name.
   
   | Text | Problem in the current text | Checked against |
   |---|---|---|
   | `operation` (endpoint path option) | It does not say that the 
CamelAlibabaSmsOperation header, and after it an exchange property of the same 
name, replace the option. | `SMSComponent.createEndpoint` and the `SMSEndpoint` 
constructor (the path of the endpoint URI), `SMSProducer.process` (an empty 
operation fails with `Operation name not found`, an unknown one with 
`Unsupported operation:` and its name), `SMSUtils.createClientConfigurations`, 
camel-alibaba-common `OpenApiClientSupport.resolveString` (the header, else the 
exchange property of the same name, else the option), `SMSProperties` (the name 
CamelAlibabaSmsOperation, which `SMSHeaders` does not declare). In a run, the 
header CamelAlibabaSmsOperation with the value querySendDetails and the 
exchange property of that name with that value each failed the exchange with 
`Unsupported operation: querySendDetails`, and no request was sent. In the same 
run, the header with the value sendsms also failed the exchange as an 
unsupported
  operation, and no request was sent. The ots and fc text word for word, with 
the sms header name. The tests use only the path value sendSms. |
   | `region` (endpoint option) | It does not say that the value is a region 
ID, that it only determines the endpoint when the endpoint option is not set, 
nor that it is not used when smsClient is set or autowired. | 
`SMSUtils.createClient` and `createTeaConfig` (region or endpoint is required, 
and the region goes into the SDK configuration only when it is not empty; no 
other Camel code reads the option), `SMSEndpoint.initClient`, 
`DefaultEndpoint.doInit` with the generated `SMSEndpointConfigurer` (a single 
`Client` in the registry is autowired into smsClient); SMS SDK `Client` (a set 
endpoint is used as it is, else the host of the region in its endpoint map of 
17 regions, and for any other region a host from `com.aliyun:endpoint-util` 
0.0.8 that does not contain the region); tea-openapi `Client` (the region ID is 
read only by `execute`, which sendSms does not use, because Camel sets no 
signature version or algorithm). In a run without sending, the client that the 
Camel endpoint crea
 ted gave the host dysmsapi.aliyuncs.com for cn-hangzhou, 
dysmsapi.ap-southeast-1.aliyuncs.com for ap-southeast-1, 
dysmsapi-proxy.cn-beijing.aliyuncs.com for cn-beijing, and 
dysmsapi.eu-central-1.aliyuncs.com for eu-central-1. A probe of the SDK alone 
sent requests to 127.0.0.1 with the regions cn-hangzhou and eu-central-1 and 
without a region, and apart from the date, the nonce and the signature, the 
requests were the same. The region on the doc page and in 
`testconfiguration.properties` (cn-hangzhou), and the region id of the 
tea-openapi `Config` Javadoc. The fc text with Short Message Service and 
smsClient, with "to determine", the verb of the endpoint text, in place of "to 
build". The tests set the region, but they set smsClient as well, so the region 
is not used. |
   | `endpoint` (endpoint option) | It calls the value a URL, although the SDK 
takes a host name and every request fails when the value has http:// or 
https://, and "Carries higher precedence than region based client 
initialization" does not say what happens. | `SMSUtils.createClient` and 
`createTeaConfig` (one of region and endpoint is required, Camel checks nothing 
else); SMS SDK `Client.getEndpoint` (a set endpoint is used as it is); 
tea-openapi `Client` (the endpoint is the host of each request, and the 
protocol is the HTTPS of sendSms, because Camel sets no protocol). In a run, 
the client that the Camel endpoint created with the endpoint `127.0.0.1:{port}` 
sent a TLS handshake record to a plain socket on that port, so the requests use 
HTTPS, and a port after the host name is kept. In a run in which the Camel 
endpoint created the client with the endpoint `https://127.0.0.1:{port}`, the 
local server on that port received no request, and the exchange failed, so with 
a scheme no req
 uest reaches the given host. The tea-openapi `Config` Javadoc (the example 
endpoint cs.aliyuncs.com, without a scheme). The fc text with Short Message 
Service and smsClient. 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 
smsClient. | `SMSUtils.createTeaConfig`, camel-alibaba-common 
`OpenApiClientSupport.resolveAccessKey` (the option, else the accessKey of 
serviceKeys, else an IllegalArgumentException), `SMSEndpoint.initClient` (a set 
or autowired client is returned before any key is read), 
`DefaultEndpoint.doInit`; tea-openapi `Client` (a credential from accessKeyId 
and accessKeySecret, and the ACS3-HMAC-SHA256 Authorization header, which 
carries the AccessKey ID and is signed with the AccessKey secret). The ots and 
fc text word for word, with Short Message Service and smsClient. |
   | `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 
smsClient. | `SMSUtils.createTeaConfig`, 
`OpenApiClientSupport.resolveSecretKey` (as `accessKey`), 
`SMSEndpoint.initClient`, `DefaultEndpoint.doInit`; tea-openapi `Client` (the 
AccessKey secret signs the request). The ots and fc text word for word, with 
Short Message Service and smsClient. |
   | `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), 
`SMSUtils.createClient`, `SMSEndpoint.initClient`, `DefaultEndpoint.doInit`. 
The ots and fc text word for word, with smsClient. |
   | `phoneNumbers` (endpoint option) | It does not say how several phone 
numbers are written or how many are allowed, that a header and an exchange 
property replace the option, nor that one of the three is required. | 
`SMSUtils.createClientConfigurations` and `OpenApiClientSupport.resolveString` 
(as `operation`), `SMSProducer.sendSms` (an empty value fails with `Phone 
numbers, sign name and template code are required for sendSms` before any 
request, and the value is the PhoneNumbers of the request, sent as it is); SMS 
SDK `SendSmsRequest` (several numbers are separated with commas, up to 1,000 
numbers per request, and the parameter is required); neither the SDK nor the 
producer checks the count or the format. In a run, the option 
13800138000,13900139000 was sent as the PhoneNumbers 13800138000,13900139000. 
In another run, the same option written with RAW() was sent in the same way. In 
a run with the header, the exchange property and the option, the header won 
over the exchange prope
 rty and the option, the exchange property won over the option, and a blank 
header fell through to the exchange property. In a run with the header blank 
and no option, the exchange failed with the message above, and no request was 
sent. The sentences on the header and the exchange property are those of the 
ots and fc option texts, and "One of the three is required." is that of the fc 
texts. The tests send the option value 13800138000 to the mock and to the local 
server, and no test sets two numbers, the header or the exchange property. |
   | `signName` (endpoint option) | It does not say that the sign name must be 
approved, that a header and an exchange property replace the option, nor that 
one of the three is required. | `SMSUtils.createClientConfigurations` and 
`OpenApiClientSupport.resolveString` (as `operation`), `SMSProducer.sendSms` 
(as `phoneNumbers`); SMS SDK `SendSmsRequest` (a signature that has been 
approved, and the parameter is required); the doc page (approved templates and 
sign names). In the run of `phoneNumbers` with the header, the exchange 
property and the option, the header won over the exchange property and the 
option for the sign name too, and without the header the exchange property won. 
In a run without a sign name, the exchange failed with the message of 
`phoneNumbers`, and no request was sent. The sentences on the header and the 
exchange property are those of the ots and fc option texts, and "One of the 
three is required." is that of the fc texts. The tests send the option value 
CamelTest t
 o the mock and to the local server, and no test sets the header or the 
exchange property. |
   | `templateCode` (endpoint option) | It does not say that the template must 
be approved, that a header and an exchange property replace the option, nor 
that one of the three is required. | `SMSUtils.createClientConfigurations` and 
`OpenApiClientSupport.resolveString` (as `operation`), `SMSProducer.sendSms` 
(as `phoneNumbers`); SMS SDK `SendSmsRequest` (the code of a template that has 
been approved, and the parameter is required) and the doc page (approved 
templates), which call the template approved, not the code. In the run of 
`phoneNumbers` with the header, the exchange property and the option, the 
header won over the exchange property and the option for the template code too, 
and without the header the exchange property won. The sentences of `signName`, 
except the second. The tests send the option value SMS_123456 to the mock and 
to the local server. |
   | `templateParam` (endpoint option) | It does not say what the JSON holds, 
that a header and an exchange property replace the option, nor what happens 
when it is not set. | `SMSUtils.createClientConfigurations` and 
`OpenApiClientSupport.resolveString` (as `operation`), `SMSProducer.sendSms` 
(the TemplateParam of the request, only when the value is not empty, sent as it 
is); SMS SDK `SendSmsRequest` (the values for the template variables as a JSON 
string, which must provide a value for each variable) and `Client` 
(TemplateParam only when it is set). In a run with only the three required 
options, the request had no TemplateParam. In a run with the option 
{"code":"1234"} written with RAW(), the value was sent as it is. In a run with 
the same value as the doc page writes it, without RAW(), the value was sent as 
it is. In a run with an empty header and no option, the request had no 
TemplateParam. In the run of `phoneNumbers` with the header, the exchange 
property and the option, the he
 ader won over the exchange property and the option for the template parameters 
too, and without the header the exchange property won. A probe of the SDK alone 
sent a value that is not JSON as it is, and the producer does not check the 
JSON either. The sentences on the header and the exchange property are those of 
the ots and fc option texts, and the last sentence has the form of the fc 
qualifier text. No test sets the option, the header or the exchange property. |
   | `outId` (endpoint option) | It does not use the SDK term external 
transaction ID, nor say that a header and an exchange property replace the 
option, or what happens when it is not set. | 
`SMSUtils.createClientConfigurations` and `OpenApiClientSupport.resolveString` 
(as `operation`), `SMSProducer.sendSms` (the OutId of the request, only when 
the value is not empty, sent as it is); SMS SDK `SendSmsRequest` (The external 
transaction ID.) and `Client` (OutId only when it is set). In the run with only 
the three required options, the request had no OutId either. In a run with the 
option out-1, the request had the OutId out-1. In the run of `phoneNumbers` 
with the header, the exchange property and the option, the header won over the 
exchange property and the option for the external transaction ID too, and 
without the header the exchange property won. The sentences of `templateParam` 
without the parts on the JSON string, with the term of the SDK Javadoc, because 
out id appears in no pro
 se of the component: not in the body type texts, an error message or the doc 
page. No test sets the option, the header or the exchange property. |
   | `smsClient` (endpoint option) | It does not say what the option replaces, 
nor who creates the client and when. | `SMSEndpoint` (`initClient`, 
`setSmsClient` and its flag, `doStop`, which drops the reference to a client 
that the Camel endpoint created and closes nothing), `SMSProducer.process` (it 
calls `initClient` while its own reference is null, so for the first message 
that passes the check of the operation), the generated `SMSEndpointConfigurer` 
(`getAutowiredNames`), `DefaultEndpoint.doInit` (an autowired option that is 
null gets the single bean of its type in the registry); SMS SDK `Client`, which 
extends the tea-openapi `Client` (neither has a method to close or shut down 
the client, so the sentences of the otsClient text about shutting down are left 
out). In a run with one `Client` bean in the registry and no smsClient, region, 
endpoint, accessKey or secretKey in the URI, the Camel endpoint used that bean, 
and the request reached the local server. In a run without a clie
 nt and without sending, the Camel endpoint created a client from the region, 
failed with `Region or endpoint is required` when neither was set, and failed 
with `Authentication parameter 'access key (AK)' not found` when no key was 
set. The fc text word for word, with the sms class. `SendSmsTest` sets 
smsClient with a Mockito mock, and `SendSmsRealClientTest` binds a real client 
with the protocol HTTP against a local server. No test covers creating the 
client, autowiring without the URI reference or `doStop`. |
   | `CamelAlibabaSmsPhoneNumbers` (header) | It does not say that the header 
replaces the phoneNumbers option, nor how several phone numbers are written. | 
As `phoneNumbers`: `SMSUtils.createClientConfigurations` and 
`OpenApiClientSupport.resolveString`. In the run with the header, the exchange 
property and the option, the header won over the exchange property and the 
option, and without the header the exchange property won, and the same held for 
the four other input headers. The sentences on the option that the header 
replaces and on the exchange property are those of the ots and fc header texts. 
No test sets the header. |
   | `CamelAlibabaSmsSignName` (header) | It does not say that the header 
replaces the signName option, nor that the sign name must be approved. | As 
`signName`: `SMSUtils.createClientConfigurations`, and the run of 
`CamelAlibabaSmsPhoneNumbers`. The sentences on the option that the header 
replaces and on the exchange property are those of the ots and fc header texts. 
No test sets the header. |
   | `CamelAlibabaSmsTemplateCode` (header) | It does not say that the header 
replaces the templateCode option, nor that the template must be approved. | As 
`templateCode`: `SMSUtils.createClientConfigurations`, and the run of 
`CamelAlibabaSmsPhoneNumbers`. The sentences on the option that the header 
replaces and on the exchange property are those of the ots and fc header texts. 
No test sets the header. |
   | `CamelAlibabaSmsTemplateParam` (header) | It does not say that the header 
replaces the templateParam option, nor what the JSON holds. | As 
`templateParam`: `SMSUtils.createClientConfigurations` and 
`SMSProducer.sendSms`, and the run of `CamelAlibabaSmsPhoneNumbers`. The 
sentences on the option that the header replaces and on the exchange property 
are those of the ots and fc header texts. No test sets the header. |
   | `CamelAlibabaSmsOutId` (header) | It does not say that the header replaces 
the outId option, and out id is not a term. | As `outId`: 
`SMSUtils.createClientConfigurations` and `SMSProducer.sendSms`, and the run of 
`CamelAlibabaSmsPhoneNumbers`. The sentences on the option that the header 
replaces and on the exchange property are those of the ots and fc header texts. 
No test sets the header. |
   | `CamelAlibabaSmsRequestId` (header) | It does not say who sets the header, 
nor when. | `SMSProducer.sendSms` (after the call returns, the RequestId of the 
response body, when the body is not null and the RequestId is not empty; the 
producer does not check the Code of the body); SMS SDK `SendSmsResponseBody` 
(The Request ID.); tea-openapi `Client` (for a status code from 400 to 599 the 
SDK throws a com.aliyun.tea.TeaException unless returnErrorResponse is set, 
which Camel does not do, and sendSms does not retry). In a run with a 200 
response with the Code OK, the header was set. In a run with a 200 response 
with the Code isv.BUSINESS_LIMIT_CONTROL, the exchange did not fail, and the 
header was set. In a run with a 400 response, the exchange failed with a 
com.aliyun.tea.TeaException after one request, and the header was not set. A 
run with a 500 response ended in the same way. A run with a 429 response 
without Retry-After ended in the same way. A run with a 429 response with Retry
 -After ended in the same way. In a run with a client set with 
returnErrorResponse true, the 400 response did not fail the exchange: the body 
Map had the statusCode 400, and the header was the request ID of the error 
body. In a run with a 200 response without a RequestId and an earlier request 
ID header on the message, that earlier value stayed in place. This is why the 
text says "unless the exchange fails" and not "when the operation succeeds". 
The ots text with Short Message Service, with the condition of the fc texts. 
`SendSmsTest` checks the header, and `SendSmsRealClientTest` does not. |
   
   ## Found in the review, not changed here
   
   - `region` has `@Metadata(required = true)`, but the code needs `region` or 
`endpoint`, and neither when `smsClient` is set or autowired: a run with one 
`Client` bean in the registry and none of the three in the URI worked. The 
catalog validation, run by a checker of the review on the code before this 
change, reports `region` as a missing required option for a URI with only 
`endpoint`, and also for a URI with only `smsClient`.
   - `SMSHeaders` has no constant for `CamelAlibabaSmsOperation`, which the 
producer reads like the other input headers, as a run showed. Only 
`SMSProperties` declares it, so the header is missing from the header list of 
the component JSON, the endpoint DSL and the doc page, and only the `operation` 
text names it.
   - `SMSProperties` has `@Metadata` with texts of its own on its seven header 
names, but the build reads only the headers class `SMSHeaders` and its 
supertypes, so these texts are not used. Its `REQUEST_ID` text (Request id 
returned by SMS API) already differs from the text in `SMSHeaders`, and 
`OPERATION` is only there. If these texts stay, they drift from the header 
texts of this pull request.
   - `SMSEndpoint.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.
   - The client is created when the producer processes its first message, not 
when the route starts. An empty `region` and `endpoint`, or a missing AccessKey 
pair, shows up only then, and an unknown operation or a missing phone number, 
sign name or template code fails only after the client exists. This rests on 
reading the producer code.
   - The producer does not check the Code of the response body. A response 
whose Code is not OK, such as isv.BUSINESS_LIMIT_CONTROL, does not fail the 
exchange when its status code is below 400: the body Map holds the code and the 
message, and the request ID header is set, as a run showed. So a successful 
exchange with a request ID does not mean that the Code is OK, which the SDK 
Javadoc gives as the sign of a successful request. The doc page does not say 
so. Whether Short Message Service answers such errors with a 2xx status was not 
checked, because no request was sent to it.
   - The producerIn body type text, added by CAMEL-24961, says that sendSms 
takes the phone numbers, sign name, template code and template parameters from 
options or headers. It leaves out the external transaction ID (`outId`) and the 
exchange properties. This pull request changes only option and header texts, so 
this text stays as it is.
   
   # 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-sms`, `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:dysmsapi20170525` 4.6.0.
   
   _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]

Reply via email to