feat(build): 阶段0 冒烟底座(ACM2-10 U01–U04)

- U01:接入 KSP(kotlin-ksp 2.3.0)+micronaut-inject-kotlin,Micronaut BeanDefinition 由 0→94 个生成;
  移除 processing.annotations 业务包过滤(N23)
- U02:补 Gradle wrapper(9.6.1);版本矩阵单一来源——micronaut 固定 5.1.3(gradle.properties
  micronaut.version,平台 BOM 最高发布版)、JDK25 口径统一、snakeyaml 版本入 catalog;
  新增 .github/workflows/ci.yml 与 Dockerfile;.gitignore 补 .kotlin/.opencode/.zcode/.gradle-*
- U03:application.yml 键位修正(datasources.default/flyway.datasources.default/kafka.producers.default),
  移除 logstash 死配置块、logback env 统一 MSGX_LOGSTASH_*;新增 application-dev.yml(/env、/beans
  仅开发放开);PipelineProps 四嵌套类补 @ConfigurationProperties;新增 PipelinePropsBindingTest
  (改值—回读离线验收,Micronaut Test 5.x 用 TestPropertyProvider)
- U04:README「数据库初始化」与 V2.0.0 脚本头声明 CMINMSGS legacy 前置(全新库需先建旧表)
This commit is contained in:
windyboy
2026-09-06 17:59:07 +08:00
parent 38d5cecfac
commit 821da1334c
18 changed files with 558 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
name: CI
# U02(R07):最小 CI 门禁——推送/PR 即构建+测试(T17 门禁的载体)
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '25'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build and test
run: ./gradlew --no-daemon build --console=plain
+15
View File
@@ -1,5 +1,20 @@
# --- 构建/工具产物 ---
.gradle/
# 本地构建缓存(本机 Gradle 用户目录,U02)
.gradle-home/
# 本地 Gradle/Java tmp(U02:环境约束,需放可执行文件系统)
.gradletmp/
build/
out/
# Kotlin 增量编译目录(R07
.kotlin/
# --- IDE / 本地工具 ---
*.iml
.idea/
# 本地 agent 工具目录(R07
.opencode/
.zcode/
# --- 系统 ---
.DS_Store
+16
View File
@@ -0,0 +1,16 @@
# U02(R07):最小容器化——两层镜像(构建 + 运行)。本地验证:docker build -t msgexchange-v2 .
# 运行时通过环境变量注入口令/端点(零入库):MSGX_DB_URL/MSGX_DB_USER/MSGX_DB_PASSWORD/
# MSGX_REDIS_URI/MSGX_KAFKA_SERVERS/MSGX_EUREKA_URL(可选)等,见 src/main/resources/application.yml。
FROM eclipse-temurin:25-jdk AS build
WORKDIR /app
COPY gradlew gradlew.bat settings.gradle.kts build.gradle.kts gradle.properties ./
COPY gradle ./gradle
RUN ./gradlew --no-daemon dependencies --console=plain >/dev/null 2>&1 || true
COPY src ./src
RUN ./gradlew --no-daemon installDist --console=plain
FROM eclipse-temurin:25-jre
WORKDIR /app
COPY --from=build /app/build/install/msgexchange-v2/ ./
EXPOSE 8080
ENTRYPOINT ["bin/msgexchange-v2"]
+18 -2
View File
@@ -43,13 +43,29 @@
4. **仓储实装**`infra/persistence/Repositories.kt` 目前是接口(Micronaut Data JDBC
实装属阶段 1 后续),主泵/调度循环以接口驱动,纯逻辑已抽离可单测。
## 数据库初始化(U04/R01,务必先读)
`db/migration/V2.0.0__aux_tables.sql` **只建六张辅助表**PROC_STATE / MSG_EVENT / REF_DATA /
REQ_TRACK / PUMP_JOB / FLIGHT_STATE),并假定 `CMINMSGS`(及其历史表)等 legacy 旧表已存在——
迁移集是「现网 legacy 库的演进」而非「全新库初始化」。因此:
- **现网/影子演进**:在既有 `cdairport` 库(含 CMINMSGS)上执行即可,Flyway 会补跑 V2.0.0。
- **全新空库(本机/CI/演练/灾备重建)**:需先按 legacy 仓库(`airport_chengdu_msgexchange_api`
建好 CMINMSGS/CMINMSGS_HST/COUTMSGS 等旧表(或从现网导出 schema),再启动本服务;否则
收报第一句 SQL 即报「表不存在」。影子实例在独立 schema 执行同一脚本时同样先建旧表。
- 为什么没有 CMINMSGS 的 V1 迁移:六表之外的旧 schema 归 legacy 仓库维护(冻结期),
本仓库不重复声明;若未来要求空库一键初始化,再补 V1 基线快照(见 ACM2-10 U04)。
## 构建
```bash
gradle build # 需网络拉取依赖;内网环境见 gradle.properties 注释
gradle test # 纯逻辑单测(identity / schd 聚合)
./gradlew build # 需网络拉取依赖;内网环境见 gradle.properties 注释
./gradlew test # 纯逻辑单测(identity / schd 聚合 / 配置绑定
```
> 注解处理:Kotlin 侧经 KSP`kotlin-ksp` + `micronaut-inject-kotlin`)生成 Micronaut
> BeanDefinitionU01);若 build 产物缺少 `*$Definition` 类,先检查 KSP 是否生效。
## 关联
Plane `airport_chengdu_msgexchange_api`ACMA-9(本阶段跟踪)、ACMA-8 v4(架构)、
+8 -2
View File
@@ -1,5 +1,6 @@
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.ksp) // U01Kotlin 注解处理(无 KSP/kapt 则 Micronaut 不生成 BeanDefinition
alias(libs.plugins.micronaut.application)
}
@@ -26,11 +27,15 @@ micronaut {
testRuntime("junit5")
processing {
incremental(true)
annotations("com.gzzn.omms.msgexchange.nextgen.*")
// U01N23):processing.annotations 语义是“注解所在包”的过滤,业务包路径不匹配任何 Micronaut
// 注解,已移除(取默认),避免增量注解处理被错误过滤;注解处理由 kotlin-ksp + micronaut-inject-kotlin 承担。
}
}
dependencies {
// U01Micronaut Kotlin 注解处理器(KSP),生成 @Singleton/@Controller/@ConfigurationProperties 的 BeanDefinition
ksp(libs.micronaut.inject.kotlin)
implementation(libs.bundles.micronaut.runtime)
implementation(libs.micronaut.data.jdbc)
implementation(libs.micronaut.jdbc.hikari)
@@ -43,9 +48,10 @@ dependencies {
implementation(libs.logstash.logback.encoder)
runtimeOnly(libs.mysql.connector.j)
runtimeOnly("org.yaml:snakeyaml")
runtimeOnly(libs.snakeyaml) // U02:显式版本入 catalog(原无版本号依赖 BOM 覆盖,snakeyaml 不在 micronaut BOM 内)
testImplementation(libs.junit.jupiter)
testRuntimeOnly(libs.h2) // U03:配置绑定回归测试的测试库(内存 datasource,冒烟用)
testImplementation("io.micronaut.test:micronaut-test-junit5")
testImplementation("org.jetbrains.kotlin:kotlin-test")
}
+4 -1
View File
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx1g
kotlin.code.style=official
# 阶段 0 锁定版本冒烟通过后,可将依赖镜像指向内网 Maven 仓库(沿用现网环境前提)
# 阶段 0 冒烟锁定(U02/T13):io.micronaut.application 插件经 micronaut.version 选择注入的
# micronaut-platform BOM 版本——平台 BOM 仅发布至 5.1.35.1.10 无对应平台 BOMKSP 会解析失败)。
# 内网环境可将依赖镜像指向内网 Maven 仓库(沿用现网环境前提)
micronaut.version=5.1.3
+14 -4
View File
@@ -1,13 +1,19 @@
# 版本为 ACMA-6 定稿口径(Micronaut 5.1 / Kotlin 2.3 / JDK 21)。
# 注意:具体版本号在阶段 0「锁定版本互操作冒烟」(现网 Eureka/logstash/ES)通过后固化,
# 见 ACMA-8 遗留开放点与 ACMA-9 Checks。
# 版本矩阵(阶段0 冒烟实测固化 · 2026-09-06 · 见 ACM2-10 U02/U03
# - JDK 25Micronaut 5.1 系构件要求 JVM 25+build.gradle.kts toolchain=25,实测可构建)。
# - Micronaut:版本由 gradle.properties `micronaut.version` 统一驱动(=5.1.3micronaut-platform BOM
# 最高发布版本;5.1.10 仅有 core 补丁无对应平台 BOM,KSP 处理器类路径会解析失败)。
# 下方 micronaut = "5.1.3" 作为 ksp 处理器(micronaut-inject-kotlin)的版本来源,勿再回落 5.1.0 / JDK21 旧口径。
# - Kotlin 2.3.0 + KSP 2.3.0Kotlin 2.3 配套版;注解处理必需,否则 Micronaut 不生成 BeanDefinition)。
[versions]
micronaut = "5.1.0"
kotlin = "2.3.0"
micronaut = "5.1.3"
ksp = "2.3.0"
junit = "5.11.4"
snakeyaml = "2.4"
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
micronaut-application = { id = "io.micronaut.application", version = "4.6.0" }
[libraries]
@@ -20,11 +26,15 @@ micronaut-redis-lettuce = { module = "io.micronaut.redis:micronaut-redis-lettuce
micronaut-kafka = { module = "io.micronaut.kafka:micronaut-kafka" }
micronaut-discovery-eureka = { module = "io.micronaut.discovery:micronaut-discovery-client" }
micronaut-management = { module = "io.micronaut:micronaut-management" }
# Kotlin 注解处理(KSP)处理器——与 kotlin-ksp 插件配套(U01
micronaut-inject-kotlin = { module = "io.micronaut:micronaut-inject-kotlin", version.ref = "micronaut" }
jackson-dataformat-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml", version = "2.18.2" }
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version = "2.18.2" }
logstash-logback-encoder = { module = "net.logstash.logback:logstash-logback-encoder", version = "8.0" }
mysql-connector-j = { module = "com.mysql:mysql-connector-j", version = "9.1.0" }
snakeyaml = { module = "org.yaml:snakeyaml", version.ref = "snakeyaml" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
h2 = { module = "com.h2database:h2", version = "2.3.232" }
[bundles]
micronaut-runtime = [
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+248
View File
@@ -0,0 +1,248 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# gradlew start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh gradlew
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+82
View File
@@ -0,0 +1,82 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem gradlew startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
"%COMSPEC%" /c exit 1
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
"%COMSPEC%" /c exit 1
:execute
@rem Setup the command line
@rem Execute gradlew
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%
@@ -5,6 +5,8 @@ import java.time.Duration
/**
* ACMA-8 参数表(v4)初值;阶段 0 现网基线校准。
* U03N02):Micronaut 要求嵌套配置类同样标注 @ConfigurationProperties,否则 msgx.pipeline/schd/
* identity/consistency-check.* 全部静默回落 Kotlin 默认值(当前 yml 初值与默认值一致,现象被掩盖)。
*/
@ConfigurationProperties("msgx")
class PipelineProps {
@@ -18,6 +20,7 @@ class PipelineProps {
enum class Phase { A, B }
@ConfigurationProperties("pipeline")
class Pipeline {
var pollInterval: Duration = Duration.ofSeconds(1) // KEEP 现役节奏
var claimBatch: Int = 50
@@ -30,16 +33,19 @@ class PipelineProps {
backoffMs.drop(attempt - 1).firstOrNull()?.coerceAtMost(backoffCapMs) ?: backoffCapMs
}
@ConfigurationProperties("schd")
class Schd {
var flushPeriod: Duration = Duration.ofSeconds(3) // KEEP 现役节律
var flushLimit: Int = 500
}
@ConfigurationProperties("identity")
class Identity {
/** CONFIRM(矩阵 #11):SEQN 重置作用域确认前保持 false,计算集中此处(I3)。 */
var includeDayBoundary: Boolean = false
}
@ConfigurationProperties("consistency-check")
class ConsistencyCheck {
var onStartup: Boolean = true // 阶段 A 必选哨兵
var dailySampleRatio: Double = 0.01
+13
View File
@@ -0,0 +1,13 @@
# 开发/影子对拍环境 profile(U03/N32):放开管理端点可见性以便“改值—回读”与 /beans 装配核验。
# 生产环境不加载本 profile/env、/beans 保持默认 sensitive)。
# 启动:MICRONAUT_ENVIRONMENTS=dev ./gradlew run
micronaut:
endpoints:
env:
enabled: true
sensitive: false
beans:
enabled: true
sensitive: false
server:
port: 8080
+13 -5
View File
@@ -1,6 +1,8 @@
# =====================================================================
# msgexchange-nextgen 配置(ACMA-8 v4
# 口令/端点全部环境变量外置——零入库(ACMA-8 契约冻结 + 安全基线)
# 键位口径:Micronaut 5.1U03):datasources.* / flyway.datasources.* /
# kafka.producers.<name>.* / eureka.client.*Micronaut 原生键,勿改回 datasource 单数或 Spring 风格)。
# =====================================================================
msgx:
phase: A # A=Redis 权威(主泵单线程写,I5);B=FLIGHT_STATE 权威+投影
@@ -27,16 +29,22 @@ micronaut:
name: msgexchange-nextgen
server:
port: 8080
# 管理端点(U03/N32):/env、/beans 默认 sensitive;仅开发/影子环境放开——见 application-dev.yml
datasource:
datasources:
default:
url: ${MSGX_DB_URL}
username: ${MSGX_DB_USER}
password: ${MSGX_DB_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
flyway:
datasources:
default:
enabled: true
locations: classpath:db/migration
# U04R01):V2.0.0 只建六张辅助表,假定 CMINMSGS/CMINMSGS_HST 等 legacy 旧表已存在;
# 全新库请按 README「数据库初始化」先落 legacy schema(或 baseline),否则收报首句 SQL 会报表不存在。
redis:
uri: ${MSGX_REDIS_URI} # 阶段 A 权威存储;仅主泵线程写(I5)
@@ -45,6 +53,7 @@ kafka:
bootstrap:
servers: ${MSGX_KAFKA_SERVERS}
producers:
default: # U03/R09Micronaut Kafka 按具名 producer 解析,须有 default 层
acks: all
enable-idempotence: true
@@ -54,7 +63,6 @@ eureka:
enabled: ${msgx.register-eureka}
default-zone: ${MSGX_EUREKA_URL:http://127.0.0.1:8761/eureka}
# logstash TCP JSON 通道保留(字段兼容现网,ACMA-3 部署前提)——见 logback.xml
logstash:
host: ${MSGX_LOGSTASH_HOST:127.0.0.1}
port: ${MSGX_LOGSTASH_PORT:5044}
# logstash TCP JSON 通道保留(字段兼容现网,ACMA-3 部署前提)
# U03/N13logback 在 Micronaut 配置体系之外独立初始化,不读本文件——地址见 logback.xml
# 环境变量统一前缀 MSGX_LOGSTASH_HOST / MSGX_LOGSTASH_PORT(不要再在此处定义 logstash.* 死键)。
@@ -1,6 +1,10 @@
-- =====================================================================
-- ACMA-8 v4 数据模型(六表)· Flyway 基线迁移
-- 与 issue「综合架构设计」数据模型节逐字一致;影子实例在独立 schema 执行同一脚本。
--
-- U04/R01 前置声明:本脚本只建六张辅助表,假定 CMINMSGS/CMINMSGS_HST/COUTMSGS 等 legacy
-- 旧表已存在(本仓库不声明旧表 V1,归 legacy 仓库维护)。全新空库请先按 legacy schema
-- 建旧表再执行本脚本,否则收报首句 SQL 会报表不存在(详见 README「数据库初始化」)。
-- =====================================================================
-- ① 处理状态伴生表(不动 CMINMSGS 旧列;
+2 -1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ACMA-8/ACMA-6logstash TCP JSON 通道保留(字段兼容现网)+ MDC traceId -->
<!-- U03/N13logback 直接读环境变量(前缀 MSGX_LOGSTASH_*),与 application.yml 不再双定义 -->
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
@@ -8,7 +9,7 @@
</appender>
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${LOGSTASH_HOST:-127.0.0.1}:${LOGSTASH_PORT:-5044}</destination>
<destination>${MSGX_LOGSTASH_HOST:-127.0.0.1}:${MSGX_LOGSTASH_PORT:-5044}</destination>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeMdcKeyName>traceId</includeMdcKeyName>
</encoder>
@@ -0,0 +1,49 @@
package com.gzzn.omms.msgexchange.nextgen.config
import io.micronaut.test.extensions.junit5.annotation.MicronautTest
import io.micronaut.test.support.TestPropertyProvider
import jakarta.inject.Inject
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.time.Duration
/**
* U03N02)验收:msgx.* 嵌套键「改值—回读」离线化。
* 四个嵌套类(Pipeline/Schd/Identity/ConsistencyCheck)须标注 @ConfigurationProperties 才会被绑定;
* 未标注时下列覆盖值会静默回落 Kotlin 默认值(本测试即红)。仅注入配置 bean,不触碰仓储/DB。
* 注:Micronaut Test 5.x 移除 @Property 注解,改以 TestPropertyProvider 注入测试属性(需 PER_CLASS)。
*/
@MicronautTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PipelinePropsBindingTest : TestPropertyProvider {
override fun getProperties(): Map<String, String> = mapOf(
"msgx.pipeline.poll-interval" to "PT7S",
"msgx.pipeline.max-attempts" to "9",
"msgx.schd.flush-limit" to "321",
"msgx.identity.include-day-boundary" to "true",
"msgx.consistency-check.daily-sample-ratio" to "0.05",
)
@Inject
lateinit var props: PipelineProps
@Test
fun `nested msgx keys bind from test properties`() {
assertEquals(Duration.ofSeconds(7), props.pipeline.pollInterval)
assertEquals(9, props.pipeline.maxAttempts)
assertEquals(321, props.schd.flushLimit)
assertTrue(props.identity.includeDayBoundary)
assertEquals(0.05, props.consistencyCheck.dailySampleRatio, 1e-9)
}
@Test
fun `top-level scalars still bind`() {
assertEquals(PipelineProps.Phase.A, props.phase)
assertEquals("msgexchangeapi", props.serviceName)
assertFalse(props.registerEureka) // application-test.yml 置 false
}
}
+28
View File
@@ -0,0 +1,28 @@
# U03 配置绑定回归测试专用环境(@MicronautTest 默认 environment=test
# 目的:让 ApplicationContext 可无外部依赖启动(内存 datasource / 关闭迁移 / 关闭注册),
# 以便以「注入 PipelineProps 断言」离线验证 msgx.* 嵌套键绑定(N02 验收),不依赖 /env 端点。
datasources:
default:
url: jdbc:h2:mem:cfgtest;DB_CLOSE_DELAY=-1
username: sa
password: ""
driver-class-name: org.h2.Driver
flyway:
datasources:
default:
enabled: false
redis:
uri: redis://127.0.0.1:6379
kafka:
bootstrap:
servers: 127.0.0.1:9092
msgx:
register-eureka: false
micronaut:
server:
port: 0