You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2019/08/19 14:11:41 UTC
[rocketmq-ons-cpp] branch master updated: Add more para for factory
(#6)
This is an automated email from the ASF dual-hosted git repository.
dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-ons-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 27ab79c Add more para for factory (#6)
27ab79c is described below
commit 27ab79cbd0eaf2db411b836f90a39473849e1ebd
Author: dinglei <li...@163.com>
AuthorDate: Mon Aug 19 22:11:37 2019 +0800
Add more para for factory (#6)
---
src/main/c/native/rocketmq.h | 2 ++
src/main/cpp/sdk/common/UtilAll.cpp | 21 ++++++++++++--
.../org/apache/rocketmq/graalvm/CInterface.java | 33 +++++++++++++++++++---
3 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/src/main/c/native/rocketmq.h b/src/main/c/native/rocketmq.h
index e4385e4..69317b4 100644
--- a/src/main/c/native/rocketmq.h
+++ b/src/main/c/native/rocketmq.h
@@ -54,6 +54,8 @@ typedef struct factory_property_struct {
char *language_identifier;
char *instance_id;
int use_domain;
+ char *max_msg_cache_size_in_mb;
+ char *suspend_time_millis;
} factory_property;
typedef struct callback_func_struct {
diff --git a/src/main/cpp/sdk/common/UtilAll.cpp b/src/main/cpp/sdk/common/UtilAll.cpp
index e6e9639..9288f77 100644
--- a/src/main/cpp/sdk/common/UtilAll.cpp
+++ b/src/main/cpp/sdk/common/UtilAll.cpp
@@ -44,12 +44,17 @@ std::string UtilAll::to_string(const std::map<std::string, std::string> &prop) {
void UtilAll::init_factory_property(const ons::ONSFactoryProperty &factoryProperty, factory_property &fp,
bool is_producer) {
memset(&fp, 0, sizeof(factory_property));
- if (is_producer) {
+ string groupID(factoryProperty.getGroupId());
+ if (!groupID.empty()) {
fp.group_id = const_cast<char *>(factoryProperty.getProducerId());
-
} else {
- fp.group_id = const_cast<char *>(factoryProperty.getConsumerId());
+ if (is_producer) {
+ fp.group_id = const_cast<char *>(factoryProperty.getProducerId());
+
+ } else {
+ fp.group_id = const_cast<char *>(factoryProperty.getConsumerId());
+ }
}
fp.access_key = const_cast<char *>(factoryProperty.getAccessKey());
fp.access_secret = const_cast<char *>(factoryProperty.getSecretKey());
@@ -69,6 +74,11 @@ void UtilAll::init_factory_property(const ons::ONSFactoryProperty &factoryProper
strcpy(send_msg_timeout_millis_, send_msg_timeout_millis.c_str());
fp.send_msg_timeout_millis = send_msg_timeout_millis_;
+ string suspend_time_millis = to_string(factoryProperty.getSuspendTimeMillis());
+ char *suspend_time_millis_ = new char[suspend_time_millis.length() + 1];
+ strcpy(suspend_time_millis_, suspend_time_millis.c_str());
+ fp.suspend_time_millis = suspend_time_millis_;
+
string consume_thread_nums = to_string(factoryProperty.getConsumeThreadNums());
char *consume_thread_nums_ = new char[consume_thread_nums.length() + 1];
strcpy(consume_thread_nums_, consume_thread_nums.c_str());
@@ -104,6 +114,11 @@ void UtilAll::init_factory_property(const ons::ONSFactoryProperty &factoryProper
strcpy(max_msg_cache_size_, max_msg_cache_size.c_str());
fp.max_msg_cache_size = max_msg_cache_size_;
+ string max_msg_cache_size_in_mib = to_string(factoryProperty.getMaxMsgCacheSizeInMiB());
+ char *max_msg_cache_size_in_mib_ = new char[max_msg_cache_size_in_mib.length() + 1];
+ strcpy(max_msg_cache_size_in_mib_, max_msg_cache_size_in_mib.c_str());
+ fp.max_msg_cache_size_in_mb = max_msg_cache_size_in_mib_;
+
string ons_trace_switch = "true";
if (!factoryProperty.getOnsTraceSwitch()) {
ons_trace_switch = "false";
diff --git a/src/main/java/org/apache/rocketmq/graalvm/CInterface.java b/src/main/java/org/apache/rocketmq/graalvm/CInterface.java
index 07b64ca..cfef42d 100644
--- a/src/main/java/org/apache/rocketmq/graalvm/CInterface.java
+++ b/src/main/java/org/apache/rocketmq/graalvm/CInterface.java
@@ -69,6 +69,10 @@ public class CInterface {
static class CPropertiesDirectives implements CContext.Directives {
public List<String> getOptions() {
+ /*
+ * When Gcc version is 5.X, it support Dual_ABI, if needed, Open it.
+ * Set it to 0 as default
+ */
if ("true".equalsIgnoreCase(System.getProperty("OPEN_DUAL_ABI"))) {
System.out.println("-D_GLIBCXX_USE_CXX11_ABI=1 -I/usr/local/include");
return Arrays.asList("-D_GLIBCXX_USE_CXX11_ABI=1 -I/usr/local/include");
@@ -243,6 +247,19 @@ public class CInterface {
@CField("use_domain")
void setUseDomain(int value);
+
+ @CField("max_msg_cache_size_in_mb")
+ CCharPointer getMaxMsgCacheSizeInMb();
+
+ @CField("max_msg_cache_size_in_mb")
+ void setMaxMsgCacheSizeInMb(CCharPointer value);
+
+ @CField("suspend_time_millis")
+ CCharPointer getSuspendTimeMillis();
+
+ @CField("suspend_time_millis")
+ void setSuspendTimeMillis(CCharPointer value);
+
}
@CStruct("callback_func") interface CCallbackFunc extends PointerBase {
@@ -365,6 +382,8 @@ public class CInterface {
String sendMsgTimeoutMillis = CTypeConversion.toJavaString(property.getSendMsgTimeoutMillis());
String languageIdentifier = CTypeConversion.toJavaString(property.getLanguageIdentifier());
String instanceId = CTypeConversion.toJavaString(property.getInstanceId());
+ String maxMsgCacheSizeInMb = CTypeConversion.toJavaString(property.getMaxMsgCacheSizeInMb());
+ String suspendTimeMillis = CTypeConversion.toJavaString(property.getSuspendTimeMillis());
if (messageModel != null && !messageModel.trim().isEmpty()) {
properties.put(PropertyKeyConst.MessageModel, messageModel);
@@ -375,8 +394,11 @@ public class CInterface {
if (onsChannel != null) {
properties.put(PropertyKeyConst.OnsChannel, onsChannel);
}
- if (maxMsgCacheSize != null) {
- properties.put(PropertyKeyConst.MaxCachedMessageSizeInMiB, maxMsgCacheSize);
+ if (maxMsgCacheSize != null && Integer.valueOf(maxMsgCacheSize) > 0) {
+ properties.put(PropertyKeyConst.MaxCachedMessageAmount, maxMsgCacheSize);
+ }
+ if (maxMsgCacheSizeInMb != null && Integer.valueOf(maxMsgCacheSizeInMb) > 0) {
+ properties.put(PropertyKeyConst.MaxCachedMessageSizeInMiB, maxMsgCacheSizeInMb);
}
if (onsTraceSwitch != null) {
properties.put(PropertyKeyConst.MsgTraceSwitch, onsTraceSwitch);
@@ -387,12 +409,15 @@ public class CInterface {
if (languageIdentifier != null) {
properties.put(PropertyKeyConst.LANGUAGE_IDENTIFIER, languageIdentifier);
}
- if (sendMsgTimeoutMillis != null) {
+ if (sendMsgTimeoutMillis != null && Integer.valueOf(sendMsgTimeoutMillis) >= 0) {
int sendMsgTimeoutMillis_ = Integer.parseInt(sendMsgTimeoutMillis);
- if (sendMsgTimeoutMillis_ >= 100 && sendMsgTimeoutMillis_ < 3000) {
+ if (sendMsgTimeoutMillis_ >= 100 && sendMsgTimeoutMillis_ <= 3000) {
properties.put(PropertyKeyConst.SendMsgTimeoutMillis, sendMsgTimeoutMillis);
}
}
+ if (suspendTimeMillis != null && Integer.valueOf(suspendTimeMillis) >= 0) {
+ properties.put(PropertyKeyConst.SuspendTimeMillis, suspendTimeMillis);
+ }
if (instanceId != null) {
properties.put(PropertyKeyConst.INSTANCE_ID, instanceId);
}