rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From duhengfore...@apache.org
Subject [rocketmq-ons] 06/43: Add language identifier to support native image for cpp
Date Fri, 06 Dec 2019 04:22:28 GMT
This is an automated email from the ASF dual-hosted git repository.

duhengforever pushed a commit to branch OpenMessaging
in repository https://gitbox.apache.org/repos/asf/rocketmq-ons.git

commit 47687022311b0167e5dfb817030090c21658244c
Author: ShannonDing <libya_003@163.com>
AuthorDate: Mon Jun 17 16:44:24 2019 +0800

    Add language identifier to support native image for cpp
---
 .../src/main/java/org/apache/rocketmq/ons/api/Message.java | 14 ++++++++++----
 .../java/org/apache/rocketmq/ons/api/PropertyKeyConst.java |  2 ++
 .../ons/api/impl/rocketmq/ONSConsumerAbstract.java         |  7 ++++++-
 .../rocketmq/ons/api/impl/rocketmq/OrderProducerImpl.java  |  7 ++++++-
 .../rocketmq/ons/api/impl/rocketmq/ProducerImpl.java       |  7 ++++++-
 .../ons/api/impl/rocketmq/TransactionProducerImpl.java     |  7 ++++++-
 6 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/Message.java b/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/Message.java
index 5d1f999..db56b15 100644
--- a/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/Message.java
+++ b/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/Message.java
@@ -51,7 +51,7 @@ public class Message implements Serializable {
     }
 
 
-    void putSystemProperties(final String key, final String value) {
+    public void putSystemProperties(final String key, final String value) {
         if (null == this.systemProperties) {
             this.systemProperties = new Properties();
         }
@@ -102,7 +102,7 @@ public class Message implements Serializable {
     }
 
 
-    String getSystemProperties(final String key) {
+    public String getSystemProperties(final String key) {
         if (null != this.systemProperties) {
             return this.systemProperties.getProperty(key);
         }
@@ -135,15 +135,21 @@ public class Message implements Serializable {
         this.putSystemProperties(SystemPropKey.MSGID, msgid);
     }
 
-    Properties getSystemProperties() {
+    public Properties getSystemProperties() {
+        if (null == systemProperties) {
+            return new Properties();
+        }
         return systemProperties;
     }
 
-    void setSystemProperties(Properties systemProperties) {
+    public void setSystemProperties(Properties systemProperties) {
         this.systemProperties = systemProperties;
     }
 
     public Properties getUserProperties() {
+        if (null == userProperties) {
+            return new Properties();
+        }
         return userProperties;
     }
 
diff --git a/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/PropertyKeyConst.java
b/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/PropertyKeyConst.java
index d98d49c..6862189 100644
--- a/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/PropertyKeyConst.java
+++ b/ons-core/ons-api/src/main/java/org/apache/rocketmq/ons/api/PropertyKeyConst.java
@@ -99,4 +99,6 @@ public class PropertyKeyConst {
 
     public static final String MAX_BATCH_MESSAGE_COUNT = "maxBatchMessageCount";
 
+    public static final String LANGUAGE_IDENTIFIER = "languageIdentifier";
+
 }
diff --git a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ONSConsumerAbstract.java
b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ONSConsumerAbstract.java
index d2bb38b..5844ebc 100644
--- a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ONSConsumerAbstract.java
+++ b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ONSConsumerAbstract.java
@@ -33,6 +33,7 @@ import org.apache.rocketmq.ons.api.exception.ONSClientException;
 import org.apache.rocketmq.ons.api.impl.tracehook.OnsConsumeMessageHookImpl;
 import org.apache.rocketmq.ons.api.impl.util.ClientLoggerUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
 
 public class ONSConsumerAbstract extends ONSClientAbstract {
     final static InternalLogger LOGGER = ClientLoggerUtil.getClientLogger();
@@ -81,7 +82,11 @@ public class ONSConsumerAbstract extends ONSClientAbstract {
 
         boolean isVipChannelEnabled = Boolean.parseBoolean(properties.getProperty(PropertyKeyConst.isVipChannelEnabled,
"false"));
         this.defaultMQPushConsumer.setVipChannelEnabled(isVipChannelEnabled);
-
+        if (properties.containsKey(PropertyKeyConst.LANGUAGE_IDENTIFIER)) {
+            int language = Integer.valueOf(properties.get(PropertyKeyConst.LANGUAGE_IDENTIFIER).toString());
+            byte languageByte = (byte) language;
+            this.defaultMQPushConsumer.setLanguage(LanguageCode.valueOf(languageByte));
+        }
         String instanceName = properties.getProperty(PropertyKeyConst.InstanceName, this.buildIntanceName());
         this.defaultMQPushConsumer.setInstanceName(instanceName);
         this.defaultMQPushConsumer.setNamesrvAddr(this.getNameServerAddr());
diff --git a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/OrderProducerImpl.java
b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/OrderProducerImpl.java
index 218a8c2..651c65b 100644
--- a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/OrderProducerImpl.java
+++ b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/OrderProducerImpl.java
@@ -36,6 +36,7 @@ import org.apache.rocketmq.ons.api.impl.tracehook.OnsClientSendMessageHookImpl;
 import org.apache.rocketmq.ons.api.impl.util.ClientLoggerUtil;
 import org.apache.rocketmq.ons.api.order.OrderProducer;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
 
 public class OrderProducerImpl extends ONSClientAbstract implements OrderProducer {
     private final static InternalLogger LOGGER = ClientLoggerUtil.getClientLogger();
@@ -62,7 +63,11 @@ public class OrderProducerImpl extends ONSClientAbstract implements OrderProduce
 
 //        boolean addExtendUniqInfo = Boolean.parseBoolean(properties.getProperty(PropertyKeyConst.EXACTLYONCE_DELIVERY,
"false"));
 //        this.defaultMQProducer.setAddExtendUniqInfo(addExtendUniqInfo);
-
+        if (properties.containsKey(PropertyKeyConst.LANGUAGE_IDENTIFIER)) {
+            int language = Integer.valueOf(properties.get(PropertyKeyConst.LANGUAGE_IDENTIFIER).toString());
+            byte languageByte = (byte) language;
+            this.defaultMQProducer.setLanguage(LanguageCode.valueOf(languageByte));
+        }
         String instanceName = properties.getProperty(PropertyKeyConst.InstanceName, this.buildIntanceName());
         this.defaultMQProducer.setInstanceName(instanceName);
         this.defaultMQProducer.setNamesrvAddr(this.getNameServerAddr());
diff --git a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ProducerImpl.java
b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ProducerImpl.java
index bd1dede..2658c7a 100644
--- a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ProducerImpl.java
+++ b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ProducerImpl.java
@@ -43,6 +43,7 @@ import org.apache.rocketmq.ons.api.exception.ONSClientException;
 import org.apache.rocketmq.ons.api.impl.tracehook.OnsClientSendMessageHookImpl;
 import org.apache.rocketmq.ons.api.impl.util.ClientLoggerUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
 
 public class ProducerImpl extends ONSClientAbstract implements Producer {
     private final static InternalLogger LOGGER = ClientLoggerUtil.getClientLogger();
@@ -73,7 +74,11 @@ public class ProducerImpl extends ONSClientAbstract implements Producer
{
 //        if (properties.containsKey(PropertyKeyConst.EXACTLYONCE_DELIVERY)) {
 //            this.defaultMQProducer.setAddExtendUniqInfo(Boolean.valueOf(properties.get(PropertyKeyConst.EXACTLYONCE_DELIVERY).toString()));
 //        }
-
+        if (properties.containsKey(PropertyKeyConst.LANGUAGE_IDENTIFIER)) {
+            int language = Integer.valueOf(properties.get(PropertyKeyConst.LANGUAGE_IDENTIFIER).toString());
+            byte languageByte = (byte) language;
+            this.defaultMQProducer.setLanguage(LanguageCode.valueOf(languageByte));
+        }
         String instanceName = properties.getProperty(PropertyKeyConst.InstanceName, this.buildIntanceName());
         this.defaultMQProducer.setInstanceName(instanceName);
         this.defaultMQProducer.setNamesrvAddr(this.getNameServerAddr());
diff --git a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/TransactionProducerImpl.java
b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/TransactionProducerImpl.java
index bc03867..13ed7e4 100644
--- a/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/TransactionProducerImpl.java
+++ b/ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/TransactionProducerImpl.java
@@ -37,6 +37,7 @@ import org.apache.rocketmq.ons.api.transaction.TransactionStatus;
 import org.apache.rocketmq.ons.open.trace.core.common.OnsTraceConstants;
 import org.apache.rocketmq.ons.open.trace.core.common.OnsTraceDispatcherType;
 import org.apache.rocketmq.ons.open.trace.core.dispatch.impl.AsyncArrayDispatcher;
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
 
 public class TransactionProducerImpl extends ONSClientAbstract implements TransactionProducer
{
     private final static InternalLogger LOGGER = ClientLoggerUtil.getClientLogger();
@@ -55,7 +56,11 @@ public class TransactionProducerImpl extends ONSClientAbstract implements
Transa
 
         boolean isVipChannelEnabled = Boolean.parseBoolean(properties.getProperty(PropertyKeyConst.isVipChannelEnabled,
"false"));
         transactionMQProducer.setVipChannelEnabled(isVipChannelEnabled);
-
+        if (properties.containsKey(PropertyKeyConst.LANGUAGE_IDENTIFIER)) {
+            int language = Integer.valueOf(properties.get(PropertyKeyConst.LANGUAGE_IDENTIFIER).toString());
+            byte languageByte = (byte) language;
+            this.transactionMQProducer.setLanguage(LanguageCode.valueOf(languageByte));
+        }
         String instanceName = properties.getProperty(PropertyKeyConst.InstanceName, this.buildIntanceName());
         this.transactionMQProducer.setInstanceName(instanceName);
 


Mime
View raw message