From afdf4a7dc213d6bb6143411085042a8c0314a830 Mon Sep 17 00:00:00 2001 From: tjq Date: Sun, 22 Jan 2023 16:38:05 +0800 Subject: [PATCH] feat: worker starter use new port config name --- .../src/main/resources/application.properties | 4 ++-- .../autoconfigure/PowerJobAutoConfiguration.java | 12 ++++++++---- .../worker/autoconfigure/PowerJobProperties.java | 6 ++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/powerjob-worker-samples/src/main/resources/application.properties b/powerjob-worker-samples/src/main/resources/application.properties index c1760d8b..c7249888 100644 --- a/powerjob-worker-samples/src/main/resources/application.properties +++ b/powerjob-worker-samples/src/main/resources/application.properties @@ -3,8 +3,8 @@ spring.jpa.open-in-view=false ########### PowerJob-worker properties. ########### # Whether to enable PowerJob Worker, default is true powerjob.worker.enabled=true -# Akka port, default is 27777 -powerjob.worker.akka-port=27777 +# Transport port, default is 27777 +powerjob.worker.port=27777 # Application name, used for grouping applications. Recommend to set the same value as project name. powerjob.worker.app-name=powerjob-worker-samples # Address of PowerJob-server node(s). Ip:port or domain. Multiple addresses should be separated with comma. diff --git a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java index 906345da..77da03f3 100644 --- a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java +++ b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java @@ -46,11 +46,15 @@ public class PowerJobAutoConfiguration { /* * Configuration of worker port. Random port is enabled when port is set with non-positive number. */ - int port = worker.getAkkaPort(); - if (port <= 0) { - port = NetUtils.getRandomPort(); + if (worker.getPort() != null) { + config.setPort(worker.getPort()); + } else { + int port = worker.getAkkaPort(); + if (port <= 0) { + port = NetUtils.getRandomPort(); + } + config.setPort(port); } - config.setPort(port); /* * appName, name of the application. Applications should be registered in advance to prevent * error. This property should be the same with what you entered for appName when getting diff --git a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java index cdfe068d..5ac4181e 100644 --- a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java +++ b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java @@ -112,8 +112,14 @@ public class PowerJobProperties { /** * Akka port of Powerjob-worker, optional value. Default value of this property is 27777. * If multiple PowerJob-worker nodes were deployed, different, unique ports should be assigned. + * Deprecated, please use 'port' */ + @Deprecated private int akkaPort = RemoteConstant.DEFAULT_WORKER_PORT; + /** + * port + */ + private Integer port; /** * Address(es) of Powerjob-server node(s). Ip:port or domain. * Example of single Powerjob-server node: