Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhom1314 committed Jun 26, 2023
1 parent 3ea6708 commit 8ada6f2
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onApplicationEvent(ApplicationEvent event) {
initialize();
refresh(dtpProperties);
} catch (Exception e) {
log.error("Init third party thread pool failed.", e);
log.error("Init apache dubbo thread pool failed.", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,21 @@ private void accept(String k, Consumer v) {
if (Objects.isNull(impl)) {
return;
}
// consumer bean name replace topic name
String cusKey = defaultMqPushConsumer.getConsumerGroup();

ThreadPoolExecutor executor = null;
val consumeMessageService = impl.getConsumeMessageService();
// consumer bean name replace topic name
String cusKey = defaultMqPushConsumer.getConsumerGroup();
if (consumeMessageService instanceof ConsumeMessageConcurrentlyService) {
cusKey = NAME + "#consumer#concurrently#" + cusKey;
executor = (ThreadPoolExecutor) ReflectionUtil.getFieldValue(
ConsumeMessageConcurrentlyService.class,
CONSUME_EXECUTOR_FIELD_NAME, consumeMessageService);
cusKey = NAME + "#consumer#concurrently#" + cusKey;
} else if (consumeMessageService instanceof ConsumeMessageOrderlyService) {
cusKey = NAME + "#consumer#orderly#" + cusKey;
executor = (ThreadPoolExecutor) ReflectionUtil.getFieldValue(
ConsumeMessageOrderlyService.class,
CONSUME_EXECUTOR_FIELD_NAME, consumeMessageService);
cusKey = NAME + "#consumer#orderly#" + cusKey;
}
if (Objects.nonNull(executor)) {
val executorWrapper = new ExecutorWrapper(cusKey, executor);
Expand Down
3 changes: 3 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
<artifactId>jackson-core</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
Expand All @@ -42,6 +44,7 @@
<artifactId>gson</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class DtpExecutorProps extends TpExecutorProps {

/**
* Executor type, used in create phase, see {@link com.dtp.core.support.ExecutorType}
* Executor type, used in create phase, see {@link org.dromara.dynamictp.core.support.ExecutorType}
*/
private String executorType;

Expand Down
2 changes: 0 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@
<dependency>
<groupId>com.github.dadiyang</groupId>
<artifactId>equator</artifactId>
<version>1.0.4</version>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>2.12.6</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.dromara.dynamictp.common.entity.NotifyItem;
import org.dromara.dynamictp.common.entity.NotifyPlatform;
import org.dromara.dynamictp.core.notifier.context.BaseNotifyCtx;
Expand Down Expand Up @@ -62,7 +63,7 @@ protected String[] getNotifyReceivers(NotifyPlatform platform) {
.map(BaseNotifyCtx::getNotifyItem)
.map(NotifyItem::getReceivers)
.orElse(null);
receivers = StrUtil.isBlank(receivers) ? platform.getReceivers() : receivers;
receivers = StringUtils.isBlank(receivers) ? platform.getReceivers() : receivers;
return receivers.split(",");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import lombok.val;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.dromara.dynamictp.common.spring.ApplicationContextHolder;
import org.dromara.dynamictp.common.em.ConfigFileTypeEnum;
import org.dromara.dynamictp.common.event.RefreshEvent;
import org.dromara.dynamictp.common.properties.DtpProperties;
import org.dromara.dynamictp.common.spring.ApplicationContextHolder;
import org.dromara.dynamictp.core.DtpRegistry;
import org.dromara.dynamictp.core.handler.ConfigHandler;
import org.dromara.dynamictp.core.support.BinderHelper;
Expand Down Expand Up @@ -86,9 +86,9 @@ protected void refresh(Environment environment) {
doRefresh(dtpProperties);
}

protected void doRefresh(DtpProperties dtpProperties) {
DtpRegistry.refresh(dtpProperties);
publishEvent(dtpProperties);
protected void doRefresh(DtpProperties properties) {
DtpRegistry.refresh(properties);
publishEvent(properties);
}

private void publishEvent(DtpProperties dtpProperties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public class DtpPostProcessorRegistrar implements ImportBeanDefinitionRegistrar
private static final String BEAN_NAME = "dtpPostProcessor";

@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
BeanDefinitionRegistry registry) {
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(BEAN_NAME)) {
AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder
.genericBeanDefinition(DtpPostProcessor.class,
Expand Down
14 changes: 14 additions & 0 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
<maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-flatten.version>1.3.0</maven-flatten.version>
<ttl.version>2.12.6</ttl.version>
<equator.version>1.0.4</equator.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -296,6 +298,18 @@
<version>${native-lib-loader.version}</version>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>${ttl.version}</version>
</dependency>

<dependency>
<groupId>com.github.dadiyang</groupId>
<artifactId>equator</artifactId>
<version>${equator.version}</version>
</dependency>

<dependency>
<groupId>org.dromara.dynamictp</groupId>
<artifactId>dynamic-tp-jvmti-runtime</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.dromara.dynamictp.starter.common.spring;
package org.dromara.dynamictp.starter.common.binder;

import org.dromara.dynamictp.common.properties.DtpProperties;
import org.dromara.dynamictp.core.spring.PropertiesBinder;
Expand All @@ -32,7 +32,7 @@
import static org.dromara.dynamictp.common.constant.DynamicTpConst.MAIN_PROPERTIES_PREFIX;

/**
* PropertiesBinder related
* SpringBootPropertiesBinder related
*
* @author yanhom
* @since 1.0.3
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.dromara.dynamictp.starter.common.spring.SpringBootPropertiesBinder
org.dromara.dynamictp.starter.common.binder.SpringBootPropertiesBinder

0 comments on commit 8ada6f2

Please sign in to comment.