This commit is contained in:
2026-08-20 09:10:32 +08:00
6 changed files with 9 additions and 6 deletions
@@ -10,7 +10,7 @@ baiyue:
data-residency: ${DATA_RESIDENCY:OVERSEAS} data-residency: ${DATA_RESIDENCY:OVERSEAS}
event-dispatcher: event-dispatcher:
consumer-url: ${LASTLEG_CONSUMER_URL:http://lastleg-service:9303/internal/lastleg/events} consumer-url: ${LASTLEG_CONSUMER_URL:http://lastleg-service:9303/internal/lastleg/events}
fixed-delay: ${EVENT_DISPATCH_FIXED_DELAY:3s} fixed-delay: ${EVENT_DISPATCH_FIXED_DELAY:3000}
batch-size: ${EVENT_DISPATCH_BATCH_SIZE:50} batch-size: ${EVENT_DISPATCH_BATCH_SIZE:50}
max-attempts: ${EVENT_DISPATCH_MAX_ATTEMPTS:10} max-attempts: ${EVENT_DISPATCH_MAX_ATTEMPTS:10}
lease-duration: ${EVENT_DISPATCH_LEASE_DURATION:30s} lease-duration: ${EVENT_DISPATCH_LEASE_DURATION:30s}
@@ -23,7 +23,7 @@ public class OverseasEventDispatcher {
@Resource private EventDispatcherProperties properties; @Resource private EventDispatcherProperties properties;
private final String leaseOwner = ManagementFactory.getRuntimeMXBean().getName() + ":" + UUID.randomUUID(); private final String leaseOwner = ManagementFactory.getRuntimeMXBean().getName() + ":" + UUID.randomUUID();
@Scheduled(fixedDelayString = "${baiyue.event-dispatcher.fixed-delay:3s}") @Scheduled(fixedDelayString = "${baiyue.event-dispatcher.fixed-delay:3000}")
public void dispatch() { public void dispatch() {
for (String eventId : inboxMapper.dispatchCandidates(properties.batchSize())) { for (String eventId : inboxMapper.dispatchCandidates(properties.batchSize())) {
dispatchOne(eventId); dispatchOne(eventId);
@@ -32,7 +32,7 @@ baiyue:
region: ${REGION_CODE:OVERSEAS} region: ${REGION_CODE:OVERSEAS}
event-dispatcher: event-dispatcher:
consumer-url: ${LASTLEG_CONSUMER_URL:http://127.0.0.1:9303/internal/lastleg/events} consumer-url: ${LASTLEG_CONSUMER_URL:http://127.0.0.1:9303/internal/lastleg/events}
fixed-delay: ${EVENT_DISPATCH_FIXED_DELAY:3s} fixed-delay: ${EVENT_DISPATCH_FIXED_DELAY:3000}
batch-size: ${EVENT_DISPATCH_BATCH_SIZE:50} batch-size: ${EVENT_DISPATCH_BATCH_SIZE:50}
max-attempts: ${EVENT_DISPATCH_MAX_ATTEMPTS:10} max-attempts: ${EVENT_DISPATCH_MAX_ATTEMPTS:10}
lease-duration: ${EVENT_DISPATCH_LEASE_DURATION:30s} lease-duration: ${EVENT_DISPATCH_LEASE_DURATION:30s}
@@ -20,7 +20,7 @@ public class WarehouseDatabaseGuardConfiguration {
Matcher matcher = MYSQL_SCHEMA.matcher(url); Matcher matcher = MYSQL_SCHEMA.matcher(url);
if (!matcher.matches() || !"baiyue_lastlag_warehouse".equalsIgnoreCase(matcher.group(1))) { if (!matcher.matches() || !"baiyue_lastlag_warehouse".equalsIgnoreCase(matcher.group(1))) {
throw new IllegalStateException( throw new IllegalStateException(
"warehouse-overseas-service requires spring.datasource.url to target the baiyue_warehouse_overseas database"); "warehouse-overseas-service requires spring.datasource.url to target the baiyue_lastlag_warehouse database");
} }
return beanFactory -> { }; return beanFactory -> { };
} }
@@ -22,11 +22,14 @@ spring:
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
discovery: discovery:
server-addr: ${NACOS_SERVER_ADDR:127.0.0.1:8858}
enabled: ${NACOS_DISCOVERY_ENABLED:true} enabled: ${NACOS_DISCOVERY_ENABLED:true}
register-enabled: ${NACOS_REGISTER_ENABLED:true} register-enabled: ${NACOS_REGISTER_ENABLED:true}
group: ${NACOS_GROUP:BAIYUE} group: ${NACOS_GROUP:BAIYUE}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:public}
config.namespace: ${NACOS_NAMESPACE:public} config:
server-addr: ${NACOS_SERVER_ADDR:127.0.0.1:8858}
namespace: ${NACOS_NAMESPACE:public}
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: ${WAREHOUSE_DB_URL:jdbc:mysql://127.0.0.1:3306/baiyue_lastlag_warehouse?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true} url: ${WAREHOUSE_DB_URL:jdbc:mysql://127.0.0.1:3306/baiyue_lastlag_warehouse?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true}
@@ -19,7 +19,7 @@ class WarehouseDatabaseGuardConfigurationTest {
assertThat(properties.getProperty("spring.datasource.url")) assertThat(properties.getProperty("spring.datasource.url"))
.asString() .asString()
.contains("baiyue_lastlag_warehouse") .contains("baiyue_lastlag_warehouse")
.doesNotContain("baiyue_lastlag_warehouse"); .doesNotContain("baiyue_warehouse_overseas");
} }
@Test @Test