Claus Ibsen created CAMEL-27719:
-----------------------------------

             Summary: camel-huaweicloud-smn: TTL and tags casts fail, 
DEFAULT_SUBJECT, WARN per message, metadata
                 Key: CAMEL-27719
                 URL: https://issues.apache.org/jira/browse/CAMEL-27719
             Project: Camel
          Issue Type: Bug
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while improving the option descriptions of camel-huaweicloud-smn for 
CAMEL-23832 (commit 
https://github.com/apache/camel/commit/8a78f11666acee7c83b90394596354076cf8daae).
These are separate problems of the component; the descriptions commit only 
documents the current behavior.

h4. 1. A CamelHwCloudSmnMessageTtl exchange property that is not an Integer 
fails the exchange
{{SimpleNotificationProducer.validateServiceConfigurations()}} reads the 
property with {{(int) exchange.getProperty(SmnProperties.NOTIFICATION_TTL)}}. A 
String value, such as {{<constant>60</constant>}} in XML or {{expression: 
"60"}} in YAML, or a Long, fails with a ClassCastException. The XML and YAML 
examples of the doc page set the TTL this way, so they fail.
Proposed change: convert the property with 
{{exchange.getProperty(SmnProperties.NOTIFICATION_TTL, Integer.class)}}.

h4. 2. A CamelHwCloudSmnTemplateTags exchange property that is not a HashMap 
fails the exchange
{{SimpleNotificationProducer.performPublishMessageServiceOperations()}} casts 
the property to {{HashMap<String, String>}} for publishAsTemplatedMessage. A 
{{Map.of(...)}}, a TreeMap or another Map fails with a ClassCastException, 
although the doc page documents the type as {{Map<String, String>}}.
Proposed change: read the property as a {{Map}} (the SDK method 
{{withTags(Map<String, String>)}} takes any Map).

h4. 3. A message without a subject is published with the subject DEFAULT_SUBJECT
When the CamelHwCloudSmnSubject exchange property is not set, 
{{SimpleNotificationProducer.validateServiceConfigurations()}} sets the literal 
subject {{DEFAULT_SUBJECT}}. The subject is optional in SMN, so subscribers 
(for example by email) receive the text DEFAULT_SUBJECT instead of no subject.
Proposed change: send no subject when the property is not set (or document the 
default).

h4. 4. A WARN log for each message without a subject or a TTL property
{{SimpleNotificationProducer.validateServiceConfigurations()}} logs 
"notification subject not found" and "TTL not found" at WARN for each message 
that has no CamelHwCloudSmnSubject or CamelHwCloudSmnMessageTtl exchange 
property. Using the messageTtl endpoint option, the normal way to set the TTL, 
logs a WARN for every message.
Proposed change: log these at DEBUG.

h4. 5. The SmnClient is created without synchronization
{{SimpleNotificationProducer.process()}} checks the non-volatile {{smnClient}} 
field and creates the client on the first message. Concurrent first messages 
can each create a client.
Proposed change: create the client in {{doStart()}}, or guard the lazy creation.

h4. 6. The operation and smnService options have no enums
{{SimpleNotificationEndpoint}} accepts only publishMessageService as smnService 
and only publishAsTextMessage and publishAsTemplatedMessage as operation, but 
the metadata has no {{enums}}, so tooling cannot offer or check the values.
Proposed change: add {{enums}} to the {{@UriPath}} and {{@UriParam}}.

h4. 7. accessKey and secretKey are marked required although serviceKeys 
replaces them
{{SimpleNotificationProducer.validateAndInitializeSmnClient()}} uses the 
accessKey and secretKey of the serviceKeys option when the options are not set, 
but both options have {{@Metadata(required = true)}}. Tooling then reports an 
endpoint that uses only serviceKeys as invalid.
Proposed change: set {{required = false}} on both.

h4. 8. Missing labels on the credential and proxy options
accessKey, secretKey and serviceKeys have no {{security}} label, and proxyHost, 
proxyPort, proxyUser and proxyPassword have no {{proxy}} label, so they show in 
the common group. The sibling hwcloud-functiongraph uses these labels.
Proposed change: add {{label = "security"}} and {{label = "proxy"}}.

h4. 9. The doc page names a wrong ServiceKeys class
The section "Using ServiceKey configuration Bean" of 
{{hwcloud-smn-component.adoc}} names 
{{org.apache.camel.component.huaweicloud.smn.models.ServiceKeys}}, which does 
not exist; the class is 
{{org.apache.camel.component.huaweicloud.common.models.ServiceKeys}}. The 
tables of exchange properties also title their first column "Header".
Proposed change: fix the class name and the column title.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to