omarsmak commented on a change in pull request #4900:
URL: https://github.com/apache/camel/pull/4900#discussion_r565184340



##########
File path: 
components/camel-huaweicloud-smn/src/main/java/org/apache/camel/component/huaweicloud/smn/SimpleNotificationProducer.java
##########
@@ -0,0 +1,363 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.huaweicloud.smn;
+
+import java.util.HashMap;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.smn.v2.SmnClient;
+import com.huaweicloud.sdk.smn.v2.model.PublishMessageRequest;
+import com.huaweicloud.sdk.smn.v2.model.PublishMessageRequestBody;
+import com.huaweicloud.sdk.smn.v2.model.PublishMessageResponse;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.smn.constants.SmnConstants;
+import org.apache.camel.component.huaweicloud.smn.constants.SmnOperations;
+import org.apache.camel.component.huaweicloud.smn.constants.SmnProperties;
+import org.apache.camel.component.huaweicloud.smn.constants.SmnServices;
+import org.apache.camel.component.huaweicloud.smn.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SimpleNotificationProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(SimpleNotificationProducer.class);
+    private SmnClient smnClient;
+    private ClientConfigurations clientConfigurations;
+
+    public SimpleNotificationProducer(SimpleNotificationEndpoint endpoint) {
+        super(endpoint);
+        validateAndInitializeSmnClient((SimpleNotificationEndpoint) 
super.getEndpoint());

Review comment:
       I would move the client initialization into either one of following 
overriden methods:
   
   - `doInit()` : In case your client is static, meaning that it does not 
create any threads upon initialization, aka lazy initialization. 
[Example](https://github.com/apache/camel/blob/master/components/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java#L152)
   - `doStart()`: In case your client will create for example thread pool upon 
initialization, this better to be placed here. 
[Example](https://github.com/apache/camel/blob/master/components/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConsumer.java#L43)
   
   Also if the `SmnClient` is closable, please make sure to close in `doStop()`

##########
File path: 
components/camel-huaweicloud-smn/src/main/java/org/apache/camel/component/huaweicloud/smn/constants/SmnProperties.java
##########
@@ -0,0 +1,19 @@
+package org.apache.camel.component.huaweicloud.smn.constants;
+
+public class SmnProperties {
+
+    public SmnProperties() {
+    }
+
+    // request properties
+    public static String TEMPLATE_NAME = "CamelHwCloudSmnTemplateName";

Review comment:
       immutable `final` is missing from the constants




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to