From ba8a8c171c3f1b0b8ff6714dd1a8bd75918bb787 Mon Sep 17 00:00:00 2001 From: donghyeon-ka Date: Wed, 23 Sep 2026 17:27:09 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=A6=AC=ED=8E=99=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=A7=84=ED=96=89=EC=A4=91=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20gradle=EC=9D=80=20=EC=96=87=EA=B2=8C=20=EC=9C=A0?= =?UTF-8?q?=EC=A7=80,=20=EA=B0=81=20=EB=AA=A8=EB=93=88=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC=ED=95=98=EA=B3=A0=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=EC=97=90=20=EB=8C=80=ED=95=B4=EC=84=9C=20?= =?UTF-8?q?=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/messaging/configuration-reference.md | 8 + docs/messaging/migration-guide.md | 17 +- docs/messaging/outbox-inbox.md | 16 ++ docs/messaging/support-matrix.md | 31 ++- messaging/CLAUDE.md | 9 + .../runtime/DestructiveMessagingAdmin.java | 4 +- .../admin/runtime/ReplayService.java | 20 +- .../admin/runtime/ApprovalForgeryTest.java | 12 ++ .../admin/runtime/ReplayServiceTest.java | 77 +++++++ .../build.gradle | 21 +- .../gradle.lockfile | 112 +++++------ .../messaging/inbox/InboxPostgresIT.java | 2 +- ...g_inbox.sql => V1101__messaging_inbox.sql} | 0 .../build.gradle | 1 - .../kafka/share/KafkaShareGroupRegistrar.java | 46 +---- .../share/KafkaShareProfileValidatorTest.java | 23 ++- messaging/messaging-kafka/build.gradle | 36 ++-- messaging/messaging-kafka/gradle.lockfile | 138 ++++++------- .../kafka/KafkaAmbiguityChaosIT.java | 0 .../kafka/KafkaBrokerCertificationIT.java | 0 .../messaging/kafka/KafkaBrokerIT.java | 0 .../kafka/KafkaConsumerSettlementIT.java | 0 .../kafka/KafkaContainerFixture.java | 0 .../kafka/KafkaContainerSmokeTest.java | 0 .../messaging/kafka/KafkaReadCommittedIT.java | 0 .../kafka/KafkaTopologyValidationIT.java | 0 .../kafka/KafkaTransactionFencingIT.java | 0 .../kafka/KafkaTransactionFixtures.java | 0 .../messaging/kafka/KafkaTransactionIT.java | 0 .../kafka/KafkaConsumerRegistrar.java | 54 +++-- .../kafka/KafkaSecurityConfigurer.java | 9 +- .../kafka/KafkaConsumerRegistrarTest.java | 107 +++++++++- .../messaging/kafka/KafkaContractHarness.java | 0 .../messaging/kafka/KafkaFixtureProfiles.java | 0 .../messaging-nats-experimental/build.gradle | 1 - .../gradle.lockfile | 2 - .../build.gradle | 21 +- .../gradle.lockfile | 122 ++++++------ .../AdminOperationJournalPostgresIT.java | 2 +- .../messaging/outbox/OutboxPostgresIT.java | 6 +- .../outbox/JdbcOutboxRepository.java | 21 +- ...outbox.sql => V1001__messaging_outbox.sql} | 0 ...V1002__messaging_outbox_lease_fencing.sql} | 0 ...03__messaging_admin_operation_journal.sql} | 0 ...__messaging_outbox_canonical_metadata.sql} | 0 .../outbox/OutboxOperationsTest.java | 33 +-- .../messaging/outbox/OutboxRelayTest.java | 22 +- .../policy/DestinationProfileValidator.java | 7 + .../policy/MessagingAdmissionController.java | 46 +++-- .../DestinationProfileValidatorTest.java | 67 ++++++- .../build.gradle | 1 - .../gradle.lockfile | 16 +- messaging/messaging-rabbit/build.gradle | 20 +- messaging/messaging-rabbit/gradle.lockfile | 148 +++++++------- .../messaging/rabbit/RabbitBrokerIT.java | 0 .../rabbit/RabbitFixtureProfiles.java | 0 .../rabbit/RabbitMessagingTransport.java | 42 +++- .../RabbitPublishFailureClassifier.java | 30 ++- .../rabbit/RabbitProfileValidatorTest.java | 116 ----------- .../messaging/rabbit/RabbitRuntimeTest.java | 32 +++ .../rabbit/RabbitTopologyAndBatchTest.java | 33 +++ .../rabbit/RabbitProfileFixtures.java | 118 +++++++++++ .../reliability/OutboxRepository.java | 35 ---- .../OutboxRepositoryApiSafetyTest.java | 24 +++ .../messaging-schema-protobuf/build.gradle | 2 +- .../messaging-schema-protobuf/gradle.lockfile | 3 +- .../build.gradle | 13 ++ .../gradle.lockfile | 115 +++++++++++ .../KafkaMessagingAutoConfiguration.java | 29 ++- .../build.gradle | 12 ++ .../gradle.lockfile | 124 ++++++++++++ .../RabbitMessagingAutoConfiguration.java | 30 ++- .../messaging-spring-boot-starter/README.md | 57 ++++-- .../build.gradle | 26 ++- .../gradle.lockfile | 188 +++++++++--------- ...ssagingLiveRoundTripQualificationTest.java | 4 +- .../CompiledMessagingConfiguration.java | 32 +-- .../DefaultBatchMessagePublisher.java | 38 ++-- .../MessagingAdminAutoConfiguration.java | 5 +- .../MessagingConfigurationCompiler.java | 84 +++----- .../MessagingConfigurationKeyValidator.java | 7 + .../MessagingCoreAutoConfiguration.java | 78 +++++++- ...essagingPlatformRootAutoConfiguration.java | 3 +- .../MessagingProviderSelection.java | 8 +- .../autoconfigure/BatchPublisherTest.java | 12 ++ .../MessagingAutoConfigurationTest.java | 86 +++++++- .../MessagingConfigurationBindingTest.java | 36 ++-- .../MessagingMigrationNamespaceTest.java | 79 ++++++++ .../MessagingOutboxRelayLifecycleTest.java | 20 -- .../MessagingStarterOffContractTest.java | 47 ++++- .../build.gradle | 1 - .../gradle.lockfile | 12 +- .../SpringCloudStreamPublisherBridge.java | 9 +- .../testkit/BrokerCertificationEvidence.java | 6 +- .../testkit/BrokerFailureMatrix.java | 20 ++ .../messaging/testkit/CertifiedEvidence.java | 15 ++ .../testkit/CompatibilityMatrix.java | 3 +- .../testkit/CompatibilityMatrixTest.java | 26 ++- 98 files changed, 1999 insertions(+), 939 deletions(-) create mode 100644 messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ReplayServiceTest.java rename messaging/messaging-inbox-jdbc-postgresql/src/{test => integrationTest}/java/dev/caskeleton/messaging/inbox/InboxPostgresIT.java (98%) rename messaging/messaging-inbox-jdbc-postgresql/src/main/resources/db/migration/messaging/{V2__messaging_inbox.sql => V1101__messaging_inbox.sql} (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaAmbiguityChaosIT.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaBrokerCertificationIT.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaBrokerIT.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaConsumerSettlementIT.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaContainerFixture.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaContainerSmokeTest.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaReadCommittedIT.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaTopologyValidationIT.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaTransactionFencingIT.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaTransactionFixtures.java (100%) rename messaging/messaging-kafka/src/{test => integrationTest}/java/dev/caskeleton/messaging/kafka/KafkaTransactionIT.java (100%) rename messaging/messaging-kafka/src/{test => testFixtures}/java/dev/caskeleton/messaging/kafka/KafkaContractHarness.java (100%) rename messaging/messaging-kafka/src/{test => testFixtures}/java/dev/caskeleton/messaging/kafka/KafkaFixtureProfiles.java (100%) rename messaging/messaging-outbox-jdbc-postgresql/src/{test => integrationTest}/java/dev/caskeleton/messaging/outbox/AdminOperationJournalPostgresIT.java (99%) rename messaging/messaging-outbox-jdbc-postgresql/src/{test => integrationTest}/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java (99%) rename messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/{V1__messaging_outbox.sql => V1001__messaging_outbox.sql} (100%) rename messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/{V2__messaging_outbox_lease_fencing.sql => V1002__messaging_outbox_lease_fencing.sql} (100%) rename messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/{V3__messaging_admin_operation_journal.sql => V1003__messaging_admin_operation_journal.sql} (100%) rename messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/{V4__messaging_outbox_canonical_metadata.sql => V1004__messaging_outbox_canonical_metadata.sql} (100%) rename messaging/messaging-rabbit/src/{test => integrationTest}/java/dev/caskeleton/messaging/rabbit/RabbitBrokerIT.java (100%) rename messaging/messaging-rabbit/src/{test => integrationTest}/java/dev/caskeleton/messaging/rabbit/RabbitFixtureProfiles.java (100%) create mode 100644 messaging/messaging-rabbit/src/testFixtures/java/dev/caskeleton/messaging/rabbit/RabbitProfileFixtures.java create mode 100644 messaging/messaging-reliability-api/src/test/java/dev/caskeleton/messaging/reliability/OutboxRepositoryApiSafetyTest.java create mode 100644 messaging/messaging-spring-boot-starter-kafka/build.gradle create mode 100644 messaging/messaging-spring-boot-starter-kafka/gradle.lockfile rename messaging/{messaging-spring-boot-starter => messaging-spring-boot-starter-kafka}/src/main/java/dev/caskeleton/messaging/autoconfigure/KafkaMessagingAutoConfiguration.java (86%) create mode 100644 messaging/messaging-spring-boot-starter-rabbit/build.gradle create mode 100644 messaging/messaging-spring-boot-starter-rabbit/gradle.lockfile rename messaging/{messaging-spring-boot-starter => messaging-spring-boot-starter-rabbit}/src/main/java/dev/caskeleton/messaging/autoconfigure/RabbitMessagingAutoConfiguration.java (75%) rename messaging/messaging-spring-boot-starter/src/{test => integrationTest}/java/dev/caskeleton/messaging/autoconfigure/MessagingLiveRoundTripQualificationTest.java (98%) create mode 100644 messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingMigrationNamespaceTest.java diff --git a/docs/messaging/configuration-reference.md b/docs/messaging/configuration-reference.md index 6fa2a81..ea220b4 100644 --- a/docs/messaging/configuration-reference.md +++ b/docs/messaging/configuration-reference.md @@ -90,6 +90,8 @@ app: order-events-dlq: broker: kafka-primary kind: WORK_QUEUE + guarantees: + delivery: AT_MOST_ONCE # terminal DLQ: another DLQ is not required physical: topic: order.events.v1.dlt schema: @@ -121,6 +123,12 @@ app: | metric dimension 상한 | 200 | cardinality 폭발 방지 | `schema.codec`은 `application/json`, `schema.compatibility`는 `BACKWARD_TRANSITIVE`, + +> **현재 강제 범위:** `schema.compatibility` 값은 현재 정책 선언이며 runtime/CI에서 schema registry를 +> 조회해 호환성을 차단하지 않는다. Avro 비교기는 독립 utility/test로만 존재한다. 따라서 이 값을 +> 설정했다고 breaking schema가 자동 거부된다고 해석하면 안 된다. 실제 registry gate가 wiring되기 +> 전까지 호환성은 adopter의 schema CI가 소유한다. + `guarantees.delivery`는 `AT_LEAST_ONCE`, `retry.mode`는 `NONE`이 기본값이다. 자동 retry가 기본으로 꺼져 있는 이유는 순서를 흐트러뜨리거나 비멱등 side effect를 두 번 실행하는 retry가 눈에 보이는 실패보다 나쁘기 때문이다. diff --git a/docs/messaging/migration-guide.md b/docs/messaging/migration-guide.md index 1b849a3..77aae88 100644 --- a/docs/messaging/migration-guide.md +++ b/docs/messaging/migration-guide.md @@ -88,10 +88,23 @@ consumer recovery가 동시에 나빠지고, 유계·검증 가능한 실패가 ## DB 마이그레이션 ```text -V1__messaging_outbox.sql -V2__messaging_inbox.sql +V1001__messaging_outbox.sql +V1002__messaging_outbox_lease_fencing.sql +V1003__messaging_admin_operation_journal.sql +V1004__messaging_outbox_canonical_metadata.sql +V1101__messaging_inbox.sql ``` +Messaging owns Flyway versions `1000..1999`. The starter assembles both JDBC reliability modules, +so their migrations deliberately share `classpath:db/migration/messaging` but must never reuse a +version. Keeping them in this reserved range also prevents collisions with the application's +ordinary `db/migration/postgresql` stream, whose low-numbered versions are independent. + +When adopting outbox/inbox persistence, add `classpath:db/migration/messaging` to the deployment's +Flyway locations together with its normal application migration location. Do not copy or renumber +these files into the application's low-numbered stream; the reserved range is the namespace +boundary. + Outbox row는 business transaction과 같은 transaction에서 쓴다. Inbox reservation은 handler side effect와 같은 transaction에서 쓴다. 별도 transaction이면 각 패턴이 닫으려던 창이 그대로 열려 있다. diff --git a/docs/messaging/outbox-inbox.md b/docs/messaging/outbox-inbox.md index e28bd94..4dac3ee 100644 --- a/docs/messaging/outbox-inbox.md +++ b/docs/messaging/outbox-inbox.md @@ -9,6 +9,22 @@ **둘 다 필요하다.** Outbox만으로는 exactly-once가 되지 않는다. +## 채택할 때 먼저 적용할 DB migration + +Outbox/Inbox JDBC 모듈의 DDL은 `classpath:db/migration/messaging`에 있다. Messaging은 +Flyway version `1000..1999`를 예약해서 애플리케이션의 일반적인 저번호 migration과 버전이 +겹치지 않게 한다. + +배포에서 이 JDBC 구현을 채택할 때는 기존 Flyway location에 다음 location을 **추가**한다. + +```text +classpath:db/migration/messaging +``` + +현재 순서는 `V1001..V1004`(outbox/admin)와 `V1101`(inbox)이다. starter 테스트가 두 JDBC +모듈을 실제 combined classpath로 올려 version 중복과 예약 대역 이탈을 검사한다. 개별 DDL의 +의미와 전환 순서는 [migration-guide.md](migration-guide.md)를 따른다. + ## Outbox business transaction과 **같은 transaction**에서 row를 쓴다. 둘 다 commit되거나 둘 다 안 된다. diff --git a/docs/messaging/support-matrix.md b/docs/messaging/support-matrix.md index 38622f1..563bd88 100644 --- a/docs/messaging/support-matrix.md +++ b/docs/messaging/support-matrix.md @@ -20,18 +20,17 @@ > `FOR UPDATE SKIP LOCKED`, `ON CONFLICT`, `TIMESTAMPTZ`)이므로, 그 이름은 쓰지 않는 기술을 > 광고하고 vendor 중립 port(`messaging-reliability-api`)의 위치를 가렸다 (MSG-023). > -> 또한 registry의 messaging leaf는 모두 `runtime_memberships`가 비어 있다. 이는 **build-only / -> incubating** — 어느 composition root에도 편입되지 않았다는 뜻이며, 아래의 등급과는 다른 축이다. -> 등급은 "무엇이 증명되었는가", membership은 "무엇이 실행되는가"를 말한다. 애플리케이션에 배선하려면 -> registry를 먼저 바꾸고 `verifyRuntimeModuleMembership`을 통과시켜야 한다. 자세한 규칙은 -> `src/messaging/CLAUDE.md`가 소유한다. +> `modules.json`은 messaging leaf의 `gradle_path`와 허용 의존성을 관리하지만 +> `runtime_memberships` 필드는 없다. 실제 런타임 편입은 `app-bootstrap`의 Gradle 의존성과 starter / +> auto-configuration 경로가 결정한다. 아래 등급은 "무엇이 증명되었는가"를 말하며 런타임 편입 여부와 +> 같은 축이 아니다. 자세한 composition/cutover 상태는 `src/messaging/CLAUDE.md`가 소유한다. ## 브로커 등급 | 브로커 | 등급 | 인증 기준 | Stable 기능 | 제한 | |---|---|---|---|---| | Kafka | Stable | 4.1.x | producer idempotence, consumer group, batch, pause/resume, replay, transaction capability | Share Group은 Experimental | -| RabbitMQ | Experimental | 4.3.x | exchange/routing, publisher confirm, mandatory return, manual ACK, quorum queue, retry queue, DLQ | 장애 시나리오 레인 미실행 — 증거 없음. stream 및 특수 plugin 미지원 | +| RabbitMQ | Experimental | 4.3.x | exchange/routing, publisher confirm, mandatory return, manual ACK, quorum queue, retry queue, DLQ | **현재 starter에서 선택 불가** — production `RabbitChannelPublisher`/transport bridge가 없어 `app.messaging.broker=rabbit`은 startup에서 거부된다. 장애 시나리오 증거도 아직 없음 | | Pulsar | Experimental | 4.0 LTS + 4.2 | typed publish/consume, Shared, Key_Shared, schema | transaction 미승격, 기본 비활성 | | NATS JetStream | Experimental | 2.14.x | stream, durable consumer, explicit ACK, dedupe, replay | native DLQ 없음(플랫폼이 대행), 기본 비활성 | | Artemis/JMS | Extension | 범위 밖 | adapter SPI만 | 별도 ADR + Contract Suite 통과 필요 | @@ -153,3 +152,23 @@ delivery timeout으로 나타난다. 이를 `REJECTED`로 보고하는 것은 - 운영 application에서의 topology 파괴 작업 - 일반 애플리케이션에 raw broker client 반환 - DLQ publish 확인 전 source ACK + + +## R1 compiler status + +`adapter:outbound:messaging`의 contract/catalog/envelope compiler 군은 현재 **의도적으로 미배선**이다. +`DISABLED` + 빈 catalog/binding이 zero-resource 상태이며, 이 R1 compiler를 legacy +`MessagingConfig`에 연결해 Kafka ACK, wire compatibility, `ACTIVE_READY`, R2 qualification을 +주장하지 않는다. 코드는 다음 세대 계약을 보존하지만 현재 채택 경로가 아니며, 실제 활성화는 별도 R2 +composition/cutover에서 명시적으로 이뤄져야 한다. + + +### Optional mapping / bridge utilities + +- `messaging-cloudevents`는 starter runtime에 자동 편입되지 않는 **opt-in mapping utility**다. + 내부 envelope와 CloudEvent 객체 사이의 제한된 profile mapping을 제공하지만 binary/structured + CloudEvents wire mode 전체를 구현하거나 임의 CloudEvents producer와의 1.0 interoperability를 + 인증하지 않는다. +- `messaging-spring-cloud-stream-bridge`는 현재 `ChannelSend` seam과 publish-evidence 판단을 제공하는 + framework-neutral bridge contract다. Spring Cloud Stream `StreamBridge` dependency/auto-configuration은 + 제공하지 않으므로 shipped Spring Cloud Stream integration으로 분류하지 않는다. diff --git a/messaging/CLAUDE.md b/messaging/CLAUDE.md index dacd813..d051e29 100644 --- a/messaging/CLAUDE.md +++ b/messaging/CLAUDE.md @@ -77,6 +77,15 @@ storage/relay migration을 별도 change set으로 완료한 뒤에만 R0 seam canonical bridge의 producer identity는 `app.messaging.producer-id`로 명시한다. 값이 없으면 bridge bean을 만들지 않으며 `spring.application.name`/host/pod 이름에서 identity를 발명하지 않는다. +`ca-skeleton.outbox.canonical-transport-enabled=true`는 bridge 존재만으로 충분하지 않다. Stable +composition은 애플리케이션 계약 catalog/schema source를 임의로 만들지 않으므로 adopter가 +`IntegrationEventEncoderPort`를 명시적으로 제공해야 한다. 저장소의 후보 구현은 +`JsonSchemaIntegrationEventEncoder`이지만 이를 사용하려면 compiled contract descriptor, +`LocalJsonSchemaRegistry`, payload/envelope limits와 key material에 해당하는 application-owned 입력을 +같이 조립해야 한다. `OutboxCanonicalTransportRequirementValidator`는 publisher 또는 encoder 중 하나라도 +없으면 startup을 거부한다. 즉 canonical flag가 켜졌는데 정본 encoder가 없는 상태로 성공 기동하는 +경로는 없다. + ## Stable 승격에 필요한 증거 adapter를 Experimental → Stable로 올릴 때 필요한 것 (`docs/messaging/support-matrix.md`가 현재 diff --git a/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java b/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java index 7e6cec8..8bd50dc 100644 --- a/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java +++ b/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java @@ -1,6 +1,6 @@ package dev.caskeleton.messaging.admin.runtime; -import dev.caskeleton.messaging.admin.AdminApproval; +import dev.caskeleton.messaging.admin.VerifiedApproval; import dev.caskeleton.messaging.admin.DestructiveOperation; import dev.caskeleton.messaging.api.destination.DestinationName; import java.time.Duration; @@ -24,7 +24,7 @@ public interface DestructiveMessagingAdmin { record Approved( DestructiveOperation operation, DestinationName destination, - AdminApproval approval, + VerifiedApproval approval, long estimatedMessagesAffected) { public Approved { diff --git a/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/ReplayService.java b/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/ReplayService.java index 8aa316d..723e1ed 100644 --- a/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/ReplayService.java +++ b/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/ReplayService.java @@ -13,13 +13,10 @@ import java.util.Optional; /** * Re-reads a destination from an earlier position. * - *

An isolated replay reads alongside the live consumer and needs no approval, because it changes - * nothing: a throwaway group has its own offsets. Replaying into an existing production group is a - * different operation entirely — it rewinds a live consumer and reprocesses everything since — so - * it goes through the destructive guard. - * - *

Making the safe form free and the destructive form approved is what keeps operators from - * reaching for the destructive one out of convenience. + *

The request carries an {@code isolatedConsumerGroup} intent flag, but a caller-supplied + * boolean is not proof that the executor actually created or used an isolated broker group. + * Therefore every non-dry-run replay goes through the destructive guard until the runtime can + * attest isolation itself. Dry-run remains approval-free because it changes no broker state. */ public final class ReplayService { @@ -55,13 +52,8 @@ public final class ReplayService { Objects.requireNonNull(request, "request must not be null"); Objects.requireNonNull(approval, "approval must not be null"); - boolean needsApproval = !request.isolatedConsumerGroup(); guard.authorize( - DestructiveOperation.REPLAY, - request.destination(), - approval, - request.dryRun() || !needsApproval, - now); + DestructiveOperation.REPLAY, request.destination(), approval, request.dryRun(), now); if (request.dryRun()) { return new ReplayReport(request.replayId(), 0, true); @@ -74,7 +66,7 @@ public final class ReplayService { "REPLAY", subject, request.destination().value(), - approval.map(VerifiedApproval::ticket).orElse("isolated"), + approval.map(VerifiedApproval::ticket).orElse("dry-run"), now, Map.of( "replayId", request.replayId().toString(), diff --git a/messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ApprovalForgeryTest.java b/messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ApprovalForgeryTest.java index 38c8912..abc54be 100644 --- a/messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ApprovalForgeryTest.java +++ b/messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ApprovalForgeryTest.java @@ -187,6 +187,18 @@ class ApprovalForgeryTest { .isInstanceOf(IllegalArgumentException.class); } + @Test + @DisplayName("destructive admin plans can only carry a verified approval") + void destructiveAdminUsesTheUnforgeableApprovalType() { + assertThat( + java.util.Arrays.stream(DestructiveMessagingAdmin.Approved.class.getRecordComponents()) + .filter(component -> component.getName().equals("approval")) + .findFirst() + .orElseThrow() + .getType()) + .isEqualTo(VerifiedApproval.class); + } + @Test @DisplayName("a correctly issued approval executes") void aCorrectlyIssuedApprovalExecutes() { diff --git a/messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ReplayServiceTest.java b/messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ReplayServiceTest.java new file mode 100644 index 0000000..395ec20 --- /dev/null +++ b/messaging/messaging-admin-runtime/src/test/java/dev/caskeleton/messaging/admin/runtime/ReplayServiceTest.java @@ -0,0 +1,77 @@ +package dev.caskeleton.messaging.admin.runtime; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import dev.caskeleton.messaging.admin.DestructiveOperationGuard; +import dev.caskeleton.messaging.admin.ReplayRequest; +import dev.caskeleton.messaging.api.destination.DestinationName; +import dev.caskeleton.messaging.api.error.MessageAuthorizationException; +import java.time.Duration; +import java.time.Instant; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; +import org.junit.jupiter.api.Test; + +class ReplayServiceTest { + + private static final Instant NOW = Instant.parse("2026-09-21T00:00:00Z"); + private static final DestinationName DESTINATION = new DestinationName("orders.v1"); + + @Test + void callerClaimedIsolationDoesNotBypassApprovalForARealReplay() { + AtomicInteger executions = new AtomicInteger(); + ReplayService service = + new ReplayService( + new DestructiveOperationGuard(true), + request -> { + executions.incrementAndGet(); + return 1; + }, + event -> {}); + + ReplayRequest request = + new ReplayRequest( + UUID.fromString("0199aaaa-bbbb-7ccc-8ddd-eeeeffff1000"), + DESTINATION, + NOW.minus(Duration.ofHours(1)), + Optional.empty(), + true, + false); + + assertThatThrownBy(() -> service.replay(request, Optional.empty(), "operator", NOW)) + .isInstanceOfSatisfying( + MessageAuthorizationException.class, + failure -> assertThat(failure.failure().code()).isEqualTo("APPROVAL_REQUIRED")); + assertThat(executions).hasValue(0); + } + + @Test + void dryRunRemainsApprovalFreeEvenWhenIsolationIsOnlyAnIntentFlag() { + AtomicInteger executions = new AtomicInteger(); + ReplayService service = + new ReplayService( + new DestructiveOperationGuard(true), + request -> { + executions.incrementAndGet(); + return 1; + }, + event -> {}); + + ReplayRequest request = + new ReplayRequest( + UUID.fromString("0199aaaa-bbbb-7ccc-8ddd-eeeeffff1001"), + DESTINATION, + NOW.minus(Duration.ofHours(1)), + Optional.empty(), + true, + true); + + ReplayReport report = service.replay(request, Optional.empty(), "operator", NOW); + + assertThat(report.dryRun()).isTrue(); + assertThat(report.replayed()).isZero(); + assertThat(executions).hasValue(0); + } +} diff --git a/messaging/messaging-inbox-jdbc-postgresql/build.gradle b/messaging/messaging-inbox-jdbc-postgresql/build.gradle index 1cd44c7..bf339f0 100644 --- a/messaging/messaging-inbox-jdbc-postgresql/build.gradle +++ b/messaging/messaging-inbox-jdbc-postgresql/build.gradle @@ -1,7 +1,14 @@ plugins { + id 'ca.auxiliary-source-set' id 'ca.platform-module' } +auxiliarySourceSets { + sourceSet('integrationTest') { + compilesAgainst 'main' + } +} + dependencies { api project(':messaging:messaging-core-api') api project(':messaging:messaging-reliability-api') @@ -12,7 +19,15 @@ dependencies { // Live-database certification. The reliability patterns are claims about transaction // boundaries and uniqueness constraints, and only a real database can settle them. testImplementation project(':messaging:messaging-testkit') - testImplementation 'org.testcontainers:testcontainers-postgresql' - testImplementation 'org.testcontainers:testcontainers-junit-jupiter' - testImplementation 'org.postgresql:postgresql' + integrationTestImplementation 'org.testcontainers:testcontainers-postgresql' + integrationTestImplementation 'org.testcontainers:testcontainers-junit-jupiter' + integrationTestImplementation 'org.postgresql:postgresql' +} + +strictTestLanes { + lane('integrationTest') { + integration() + sourceSet = 'integrationTest' + description = 'Runs inbox transaction and uniqueness contracts against real PostgreSQL.' + } } diff --git a/messaging/messaging-inbox-jdbc-postgresql/gradle.lockfile b/messaging/messaging-inbox-jdbc-postgresql/gradle.lockfile index badf14e..865fc31 100644 --- a/messaging/messaging-inbox-jdbc-postgresql/gradle.lockfile +++ b/messaging/messaging-inbox-jdbc-postgresql/gradle.lockfile @@ -1,53 +1,53 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.fasterxml.jackson.core:jackson-annotations:2.21=testCompileClasspath,testRuntimeClasspath -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.docker-java:docker-java-api:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport-zerodep:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor +com.fasterxml.jackson.core:jackson-annotations:2.21=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.github.docker-java:docker-java-api:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport-zerodep:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs com.github.spotbugs:spotbugs:4.10.2=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor +com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.auto:auto-common:1.2.2=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.errorprone:error_prone_annotations:2.41.0=spotbugs com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:guava:33.5.0-jre=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins com.puppycrawl.tools:checkstyle:13.5.0=checkstyle commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-codec:commons-codec:1.19.0=testCompileClasspath,testRuntimeClasspath +commons-codec:commons-codec:1.19.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.20.0=testCompileClasspath,testRuntimeClasspath +commons-io:commons-io:2.20.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-logging:commons-logging:1.3.6=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor +io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +javax.inject:javax.inject:1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.18.1=testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.17.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.java.dev.jna:jna:5.18.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs org.antlr:antlr4-runtime:4.13.2=checkstyle org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-compress:1.28.0=testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-compress:1.28.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.apache.commons:commons-lang3:3.20.0=checkstyle,integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs org.apache.commons:commons-text:1.15.0=spotbugs org.apache.commons:commons-text:1.3=checkstyle org.apache.httpcomponents:httpclient:4.5.13=checkstyle @@ -59,48 +59,48 @@ org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.55.1=testRuntimeClasspath +org.apiguardian:apiguardian-api:1.1.2=integrationTestCompileClasspath,testCompileClasspath +org.assertj:assertj-core:3.27.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.checkerframework:checker-qual:3.55.1=integrationTestRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle org.codehaus.plexus:plexus-utils:3.3.0=checkstyle org.dom4j:dom4j:2.2.0=spotbugs org.javassist:javassist:3.28.0-GA=checkstyle -org.jetbrains:annotations:17.0.0=testCompileClasspath,testRuntimeClasspath -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath +org.jetbrains:annotations:17.0.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,integrationTestAnnotationProcessor,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-launcher:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit:junit-bom:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.junit:junit-bom:6.1.0=spotbugs org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.3.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.ow2.asm:asm-analysis:9.10.1=spotbugs org.ow2.asm:asm-commons:9.10.1=spotbugs org.ow2.asm:asm-tree:9.10.1=spotbugs org.ow2.asm:asm-util:9.10.1=spotbugs org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.postgresql:postgresql:42.7.13=testCompileClasspath,testRuntimeClasspath +org.pcollections:pcollections:4.0.1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +org.postgresql:postgresql:42.7.13=integrationTestCompileClasspath,integrationTestRuntimeClasspath org.reflections:reflections:0.10.2=checkstyle -org.rnorth.duct-tape:duct-tape:1.0.8=testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath +org.rnorth.duct-tape:duct-tape:1.0.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.slf4j:slf4j-api:2.0.18=integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs,spotbugsSlf4j org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-jdbc:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-tx:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-database-commons:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-jdbc:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-junit-jupiter:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-postgresql:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers:2.0.5=testCompileClasspath,testRuntimeClasspath +org.springframework:spring-beans:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-core:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-jdbc:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-tx:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.testcontainers:testcontainers-database-commons:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-jdbc:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-junit-jupiter:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-postgresql:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs empty= diff --git a/messaging/messaging-inbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/inbox/InboxPostgresIT.java b/messaging/messaging-inbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/inbox/InboxPostgresIT.java similarity index 98% rename from messaging/messaging-inbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/inbox/InboxPostgresIT.java rename to messaging/messaging-inbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/inbox/InboxPostgresIT.java index a381418..367a6f5 100644 --- a/messaging/messaging-inbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/inbox/InboxPostgresIT.java +++ b/messaging/messaging-inbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/inbox/InboxPostgresIT.java @@ -196,7 +196,7 @@ class InboxPostgresIT { try (InputStream stream = InboxPostgresIT.class .getClassLoader() - .getResourceAsStream("db/migration/messaging/V2__messaging_inbox.sql")) { + .getResourceAsStream("db/migration/messaging/V1101__messaging_inbox.sql")) { if (stream == null) { throw new IOException("the inbox migration is missing from the classpath"); } diff --git a/messaging/messaging-inbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V2__messaging_inbox.sql b/messaging/messaging-inbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1101__messaging_inbox.sql similarity index 100% rename from messaging/messaging-inbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V2__messaging_inbox.sql rename to messaging/messaging-inbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1101__messaging_inbox.sql diff --git a/messaging/messaging-kafka-share-experimental/build.gradle b/messaging/messaging-kafka-share-experimental/build.gradle index fd42b56..33edc25 100644 --- a/messaging/messaging-kafka-share-experimental/build.gradle +++ b/messaging/messaging-kafka-share-experimental/build.gradle @@ -8,5 +8,4 @@ dependencies { api project(':messaging:messaging-transport-spi') api project(':messaging:messaging-kafka') - implementation 'org.apache.kafka:kafka-clients' } diff --git a/messaging/messaging-kafka-share-experimental/src/main/java/dev/caskeleton/messaging/kafka/share/KafkaShareGroupRegistrar.java b/messaging/messaging-kafka-share-experimental/src/main/java/dev/caskeleton/messaging/kafka/share/KafkaShareGroupRegistrar.java index 1442415..07c9ec1 100644 --- a/messaging/messaging-kafka-share-experimental/src/main/java/dev/caskeleton/messaging/kafka/share/KafkaShareGroupRegistrar.java +++ b/messaging/messaging-kafka-share-experimental/src/main/java/dev/caskeleton/messaging/kafka/share/KafkaShareGroupRegistrar.java @@ -4,9 +4,6 @@ import dev.caskeleton.messaging.api.error.MessagingCapabilityUnavailableExceptio import dev.caskeleton.messaging.transport.TransportConsumerRegistration; import dev.caskeleton.messaging.transport.TransportConsumerSpec; import java.util.Objects; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.atomic.AtomicBoolean; /** * Registers a share group consumer, once the experimental guard has passed. @@ -44,45 +41,8 @@ public final class KafkaShareGroupRegistrar { KafkaShareProfile profile, TransportConsumerSpec spec) { Objects.requireNonNull(spec, "spec must not be null"); validator.validate(profile); - return new ShareRegistration(profile); - } - - /** A live share group subscription. */ - private static final class ShareRegistration implements TransportConsumerRegistration { - - private final KafkaShareProfile profile; - private final AtomicBoolean active = new AtomicBoolean(true); - - private ShareRegistration(KafkaShareProfile profile) { - this.profile = profile; - } - - @Override - public CompletionStage pause(String scope) { - return CompletableFuture.failedFuture( - new MessagingCapabilityUnavailableException( - "KAFKA_SHARE_NO_PAUSE", - "a Kafka share group has no partition assignment to pause: " - + profile.destination().value())); - } - - @Override - public CompletionStage resume(String scope) { - return CompletableFuture.failedFuture( - new MessagingCapabilityUnavailableException( - "KAFKA_SHARE_NO_RESUME", - "a Kafka share group has no partition assignment to resume: " - + profile.destination().value())); - } - - @Override - public boolean isActive() { - return active.get(); - } - - @Override - public void close() { - active.set(false); - } + throw new MessagingCapabilityUnavailableException( + "KAFKA_SHARE_CONSUMER_NOT_IMPLEMENTED", + "Kafka Share registration is not implemented; refusing to advertise an active consumer"); } } diff --git a/messaging/messaging-kafka-share-experimental/src/test/java/dev/caskeleton/messaging/kafka/share/KafkaShareProfileValidatorTest.java b/messaging/messaging-kafka-share-experimental/src/test/java/dev/caskeleton/messaging/kafka/share/KafkaShareProfileValidatorTest.java index 2772f82..e2ecf9a 100644 --- a/messaging/messaging-kafka-share-experimental/src/test/java/dev/caskeleton/messaging/kafka/share/KafkaShareProfileValidatorTest.java +++ b/messaging/messaging-kafka-share-experimental/src/test/java/dev/caskeleton/messaging/kafka/share/KafkaShareProfileValidatorTest.java @@ -57,17 +57,18 @@ class KafkaShareProfileValidatorTest { } @Test - void pauseIsRefusedRatherThanSilentlyIgnored() { - var registration = - new KafkaShareGroupRegistrar() - .register( - KafkaShareProfileFixtures.profile(OrderingScope.NONE), - new dev.caskeleton.messaging.transport.TransportConsumerSpec( - KafkaShareProfileFixtures.destinationProfile(), - delivery -> java.util.concurrent.CompletableFuture.completedFuture(null))); - - assertThat(registration.pause("any").toCompletableFuture()).isCompletedExceptionally(); - assertThat(registration.isActive()).isTrue(); + void registerFailsClosedUntilAShareConsumerActuallyExists() { + assertThatThrownBy( + () -> + new KafkaShareGroupRegistrar() + .register( + KafkaShareProfileFixtures.profile(OrderingScope.NONE), + new dev.caskeleton.messaging.transport.TransportConsumerSpec( + KafkaShareProfileFixtures.destinationProfile(), + delivery -> + java.util.concurrent.CompletableFuture.completedFuture(null)))) + .isInstanceOf(MessagingCapabilityUnavailableException.class) + .hasMessageContaining("not implemented"); } } diff --git a/messaging/messaging-kafka/build.gradle b/messaging/messaging-kafka/build.gradle index a14c287..dfd0533 100644 --- a/messaging/messaging-kafka/build.gradle +++ b/messaging/messaging-kafka/build.gradle @@ -1,9 +1,18 @@ plugins { + id 'java-test-fixtures' + id 'ca.auxiliary-source-set' id 'ca.jmh-benchmarks' id 'ca.messaging-certification' } +auxiliarySourceSets { + sourceSet('integrationTest') { + compilesAgainst 'main', 'testFixtures' + } +} + dependencies { + implementation 'org.springframework.kafka:spring-kafka' api project(':messaging:messaging-core-api') api project(':messaging:messaging-schema-api') api project(':messaging:messaging-policy') @@ -12,7 +21,6 @@ dependencies { api project(':messaging:messaging-security') api project(':messaging:messaging-admin-api') - implementation 'org.springframework.kafka:spring-kafka' // api: the public constructors and mappers take and return Producer, ProducerRecord and // RecordMetadata. Hiding the dependency does not hide the types — it only stops a consumer // from compiling against the API this module documents. @@ -21,6 +29,7 @@ dependencies { // Test-only. The shared adapter contract is what makes "Stable" mean something, so the Kafka // adapter runs it rather than asserting its own behaviour in its own terms. testImplementation project(':messaging:messaging-testkit') + testFixturesImplementation project(':messaging:messaging-testkit') // Test-only. The topology validator is broker-neutral, so it lives in the admin runtime; the // live-broker suite is here because only this module has a Kafka container to describe. @@ -28,10 +37,10 @@ dependencies { // Live-broker certification. The deterministic suite proves the platform's semantics; these // prove the client actually behaves that way against the version the matrix claims. - testImplementation 'org.testcontainers:testcontainers-junit-jupiter' - testImplementation 'org.testcontainers:testcontainers-kafka' - testImplementation 'org.testcontainers:testcontainers-toxiproxy' - testImplementation libs.toxiproxy.java + integrationTestImplementation 'org.testcontainers:testcontainers-junit-jupiter' + integrationTestImplementation 'org.testcontainers:testcontainers-kafka' + integrationTestImplementation 'org.testcontainers:testcontainers-toxiproxy' + integrationTestImplementation libs.toxiproxy.java } // The certification lane, and the gate that makes its output the only source of a Stable claim. @@ -45,7 +54,7 @@ dependencies { strictTestLanes { lane('messagingCertificationTest') { integration() - tag = 'messaging-certification' + sourceSet = 'integrationTest' description = 'Runs the broker fault scenarios against a real Kafka and writes the ' + 'certification evidence the compatibility matrix reads.' // Pinned images. A certification claim names the build it was made against, so a @@ -60,7 +69,9 @@ strictTestLanes { project.layout.buildDirectory .file('messaging-certification/broker-certification-evidence.jsonl') .get().asFile.absolutePath - // The commit is part of the evidence: "certified" is a claim about one source tree. + // The commit is provenance recorded in the evidence, not an equality key for the + // behavioral claim gate. Re-running the same scenario on a later commit refreshes + // provenance without creating a different scenario identity. // Read from the environment rather than a `-P` flag so the CI job's command line stays // the literal grammar the gate matrix lint accepts. systemProperty 'messaging.certification.commit', @@ -69,14 +80,3 @@ strictTestLanes { .toString() } } - -// The certification tag is excluded from `test` because the lane deliberately carries no Docker -// guard. Every other container suite here skips with a stated reason when Docker is absent; a lane -// that skipped would report success for a broker nobody started, which is the whole failure the -// evidence exists to rule out. Keeping it out of `test` is what lets it fail closed without -// breaking a laptop build. -tasks.named('test', Test) { - useJUnitPlatform { - excludeTags 'messaging-certification' - } -} diff --git a/messaging/messaging-kafka/gradle.lockfile b/messaging/messaging-kafka/gradle.lockfile index 3bbaee7..b38d867 100644 --- a/messaging/messaging-kafka/gradle.lockfile +++ b/messaging/messaging-kafka/gradle.lockfile @@ -1,66 +1,66 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -at.yawk.lz4:lz4-java:1.10.1=jmhRuntimeClasspath,runtimeClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-annotations:2.21=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.github.docker-java:docker-java-api:3.7.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport-zerodep:3.7.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport:3.7.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.github.luben:zstd-jni:1.5.6-10=jmhRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +at.yawk.lz4:lz4-java:1.10.1=integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-annotations:2.21=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.github.docker-java:docker-java-api:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport-zerodep:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.github.luben:zstd-jni:1.5.6-10=integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs com.github.spotbugs:spotbugs:4.10.2=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.auto:auto-common:1.2.2=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs -com.google.code.gson:gson:2.13.2=jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.41.0=jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.code.gson:gson:2.13.2=integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs +com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.41.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,jmhAnnotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.guava:guava:33.5.0-jre=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,jmhAnnotationProcessor,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,jmhAnnotationProcessor,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins com.puppycrawl.tools:checkstyle:13.5.0=checkstyle commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-codec:commons-codec:1.19.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-codec:commons-codec:1.19.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.20.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-io:commons-io:2.20.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -eu.rekawek.toxiproxy:toxiproxy-java:2.1.7=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-logging:commons-logging:1.3.6=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +eu.rekawek.toxiproxy:toxiproxy-java:2.1.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -io.micrometer:micrometer-commons:1.16.7=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-core:1.16.7=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-observation:1.16.7=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +io.micrometer:micrometer-commons:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-core:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-observation:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +javax.inject:javax.inject:1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.18.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.17.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +net.java.dev.jna:jna:5.18.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath net.sf.jopt-simple:jopt-simple:5.0.4=jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs org.antlr:antlr4-runtime:4.13.2=checkstyle org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-compress:1.28.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-lang3:3.20.0=checkstyle,jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-compress:1.28.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.apache.commons:commons-lang3:3.20.0=checkstyle,integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs org.apache.commons:commons-math3:3.6.1=jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath org.apache.commons:commons-text:1.15.0=spotbugs org.apache.commons:commons-text:1.3=checkstyle org.apache.httpcomponents:httpclient:4.5.13=checkstyle org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.kafka:kafka-clients:4.1.2=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.kafka:kafka-clients:4.1.2=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.apache.logging.log4j:log4j-api:2.25.5=spotbugs org.apache.logging.log4j:log4j-core:2.25.5=spotbugs org.apache.maven.doxia:doxia-core:1.12.0=checkstyle @@ -68,54 +68,54 @@ org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=jmhCompileClasspath,testCompileClasspath -org.assertj:assertj-core:3.27.7=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apiguardian:apiguardian-api:1.1.2=integrationTestCompileClasspath,jmhCompileClasspath,testCompileClasspath,testFixturesCompileClasspath +org.assertj:assertj-core:3.27.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle org.codehaus.plexus:plexus-utils:3.3.0=checkstyle org.dom4j:dom4j:2.2.0=spotbugs -org.hdrhistogram:HdrHistogram:2.2.2=jmhRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +org.hdrhistogram:HdrHistogram:2.2.2=integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.javassist:javassist:3.28.0-GA=checkstyle -org.jetbrains:annotations:17.0.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=jmhRuntimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=jmhRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=jmhRuntimeClasspath,testRuntimeClasspath -org.junit:junit-bom:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jetbrains:annotations:17.0.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,integrationTestAnnotationProcessor,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testFixturesAnnotationProcessor,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-launcher:6.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,testRuntimeClasspath +org.junit:junit-bom:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.junit:junit-bom:6.1.0=spotbugs -org.latencyutils:LatencyUtils:2.0.3=jmhRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +org.latencyutils:LatencyUtils:2.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.mockito:mockito-core:5.20.0=mockitoAgent org.openjdk.jmh:jmh-core:1.37=jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath org.openjdk.jmh:jmh-generator-annprocess:1.37=jmhAnnotationProcessor -org.opentest4j:opentest4j:1.3.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.3.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.ow2.asm:asm-analysis:9.10.1=spotbugs org.ow2.asm:asm-commons:9.10.1=spotbugs org.ow2.asm:asm-tree:9.10.1=spotbugs org.ow2.asm:asm-util:9.10.1=spotbugs org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +org.pcollections:pcollections:4.0.1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor org.reflections:reflections:0.10.2=checkstyle -org.rnorth.duct-tape:duct-tape:1.0.8=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:2.0.18=jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath +org.rnorth.duct-tape:duct-tape:1.0.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.slf4j:slf4j-api:2.0.18=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testFixturesRuntimeClasspath,testRuntimeClasspath org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework.kafka:spring-kafka:4.0.7=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-aop:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-beans:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-context:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-expression:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-messaging:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-tx:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-junit-jupiter:2.0.5=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-kafka:2.0.5=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-toxiproxy:2.0.5=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers:2.0.5=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.xerial.snappy:snappy-java:1.1.10.7=jmhRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +org.springframework.kafka:spring-kafka:4.0.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-aop:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-beans:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-context:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-core:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-expression:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-messaging:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-tx:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.testcontainers:testcontainers-junit-jupiter:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-kafka:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-toxiproxy:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.xerial.snappy:snappy-java:1.1.10.7=integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs empty= diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaAmbiguityChaosIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaAmbiguityChaosIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaAmbiguityChaosIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaAmbiguityChaosIT.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaBrokerCertificationIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaBrokerCertificationIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaBrokerCertificationIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaBrokerCertificationIT.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaBrokerIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaBrokerIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaBrokerIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaBrokerIT.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerSettlementIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaConsumerSettlementIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerSettlementIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaConsumerSettlementIT.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaContainerFixture.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaContainerFixture.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaContainerFixture.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaContainerFixture.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaContainerSmokeTest.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaContainerSmokeTest.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaContainerSmokeTest.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaContainerSmokeTest.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaReadCommittedIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaReadCommittedIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaReadCommittedIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaReadCommittedIT.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTopologyValidationIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTopologyValidationIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTopologyValidationIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTopologyValidationIT.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTransactionFencingIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTransactionFencingIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTransactionFencingIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTransactionFencingIT.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTransactionFixtures.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTransactionFixtures.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTransactionFixtures.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTransactionFixtures.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTransactionIT.java b/messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTransactionIT.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaTransactionIT.java rename to messaging/messaging-kafka/src/integrationTest/java/dev/caskeleton/messaging/kafka/KafkaTransactionIT.java diff --git a/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrar.java b/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrar.java index 241f047..c285b5c 100644 --- a/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrar.java +++ b/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrar.java @@ -289,6 +289,8 @@ public final class KafkaConsumerRegistrar implements TransportConsumerRegistrati shutdown.endWork(); return; } + java.util.concurrent.CompletableFuture handler = null; + boolean releaseImmediately = true; try { int attempt = retryMetadataMapper.attemptOf(envelope); TransportDelivery delivery = @@ -301,19 +303,36 @@ public final class KafkaConsumerRegistrar implements TransportConsumerRegistrati profile.consumer().group().orElse(null), now), settlement); - // The declared handler timeout is applied. It existed as a policy field and the - // worker blocked on an unbounded join, so a handler that never returned held its - // partition's permit and its offset forever — the partition simply stopped. - spec.sink() - .apply(delivery) - .toCompletableFuture() - .get(handlerTimeout.toMillis(), java.util.concurrent.TimeUnit.MILLISECONDS); + // The declared handler timeout is applied. The outstanding stage is kept so timeout + // handling can cancel it before this partition becomes eligible for redelivery. + handler = spec.sink().apply(delivery).toCompletableFuture(); + handler.get(handlerTimeout.toMillis(), java.util.concurrent.TimeUnit.MILLISECONDS); } catch (java.util.concurrent.TimeoutException timedOut) { - // Unsettled work, not a completion: pause and re-read rather than advancing past a - // message whose handler may still be running. + // A timed-out handler may still be applying side effects. Cancel it before releasing + // the partition permit; otherwise the same offset can be dispatched again while the + // first handler is still running. + java.util.concurrent.CompletableFuture timedOutHandler = handler; settlement.requeueAfterFailure(); + if (timedOutHandler != null + && !timedOutHandler.cancel(true) + && !timedOutHandler.isDone()) { + releaseImmediately = false; + java.util.concurrent.CompletableFuture releaseAfterCompletion = + timedOutHandler.whenComplete( + (ignored, failure) -> { + coordinator.release(partition); + shutdown.endWork(); + }); + // Keep the continuation strongly referenced through this worker frame. The + // completion action owns the delayed permit/work-count release; its own result is + // intentionally not joined here. + Objects.requireNonNull(releaseAfterCompletion); + } } catch (InterruptedException interrupted) { Thread.currentThread().interrupt(); + if (handler != null) { + handler.cancel(true); + } settlement.requeueAfterFailure(); } catch (java.util.concurrent.ExecutionException | RuntimeException failure) { // A handler failure is retried, not parked. PARKED completed the offset without any @@ -321,8 +340,10 @@ public final class KafkaConsumerRegistrar implements TransportConsumerRegistrati // every message it touched. settlement.requeueAfterFailure(); } finally { - coordinator.release(partition); - shutdown.endWork(); + if (releaseImmediately) { + coordinator.release(partition); + shutdown.endWork(); + } } }); return true; @@ -509,10 +530,13 @@ public final class KafkaConsumerRegistrar implements TransportConsumerRegistrati // Close still runs here rather than through the queue: after this the poll loop stops, so // queued work would never drain. What it does not do is race an in-progress poll — callers // stop the loop first, and `active` makes a second close a no-op. - drainControl(); - applySettlements(); - commitContiguous(); - consumer.close(); + try { + drainControl(); + applySettlements(); + commitContiguous(); + } finally { + consumer.close(); + } } } diff --git a/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaSecurityConfigurer.java b/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaSecurityConfigurer.java index 2e1d672..e9ca621 100644 --- a/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaSecurityConfigurer.java +++ b/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaSecurityConfigurer.java @@ -19,9 +19,12 @@ import java.util.Objects; * configured from a value read once at startup holds that value until the process restarts, so the * rotation the credential store performs never reaches the broker connection. * - *

The JAAS config is assembled into a {@code String} because that is the only shape Kafka's - * client accepts, and it is deliberately never retained — the method returns the map and keeps no - * reference, so the secret's lifetime is the caller's. + *

The JAAS config is assembled into a {@code String} because that is the shape Kafka's client + * configuration accepts. The configurer keeps no field reference after returning the map, but the + * returned immutable String contains the credential and cannot be zeroized; its lifetime is the + * Kafka/client configuration lifetime. The source {@link CredentialRuntime} material is still + * zeroizable, but converting it to JAAS necessarily weakens that property and must not be described + * as if the String never existed. */ public final class KafkaSecurityConfigurer { diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java b/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java index 981b941..8270f05 100644 --- a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java +++ b/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java @@ -153,6 +153,93 @@ class KafkaConsumerRegistrarTest { assertThat(registrar.isActive()).isFalse(); } + @Test + void handlerTimeoutCancelsTheOutstandingHandlerBeforeThePartitionPermitIsReleased() { + CompletableFuture handler = new CompletableFuture<>(); + dev.caskeleton.messaging.policy.DestinationProfile base = KafkaContractHarness.profile(); + dev.caskeleton.messaging.policy.DestinationProfile fastTimeout = + new dev.caskeleton.messaging.policy.DestinationProfile( + base.name(), + base.broker(), + base.kind(), + base.physical(), + base.schema(), + base.deliveryGuarantee(), + base.orderingScope(), + base.externalSideEffectGuarantee(), + base.producer(), + new dev.caskeleton.messaging.policy.ConsumerPolicy( + base.consumer().group(), + base.consumer().concurrency(), + base.consumer().maxInFlightPerOrderingUnit(), + base.consumer().prefetch(), + Duration.ofMillis(5), + base.consumer().manualSettlement()), + base.retry(), + base.deadLetter(), + base.payload(), + base.tier(), + base.production(), + base.keyResolverConfigured(), + base.topologyAutoCreate()); + + KafkaConsumerRegistrar registrar = + new KafkaConsumerRegistrar( + new TransportConsumerSpec(fastTimeout, delivery -> handler), + consumer, + handlers, + new GracefulShutdownCoordinator(Duration.ofSeconds(30)), + Duration.ofMillis(1)); + + assign(); + addRecord(10); + registrar.pollOnce(NOW); + handlers.runAll(); + + assertThat(handler) + .as("a timed-out handler must be cancelled before the same partition can be redelivered") + .isCancelled(); + } + + @Test + void closeStillClosesTheConsumerWhenTheFinalCommitFails() { + CommitFailingConsumer failing = new CommitFailingConsumer(); + failing.assign(List.of(PARTITION)); + failing.updateBeginningOffsets(Map.of(PARTITION, 10L)); + failing.seek(PARTITION, 10L); + + RecordHeaders headers = new RecordHeaders(); + headers.add( + ReservedHeaders.MESSAGE_ID, + MessageId.newId().value().toString().getBytes(StandardCharsets.UTF_8)); + headers.add(ReservedHeaders.MESSAGE_TYPE, "order.created".getBytes(StandardCharsets.UTF_8)); + headers.add(ReservedHeaders.SCHEMA_VERSION, "1".getBytes(StandardCharsets.UTF_8)); + headers.add(ReservedHeaders.CONTENT_TYPE, "application/json".getBytes(StandardCharsets.UTF_8)); + failing.addRecord(record(10, headers)); + + KafkaConsumerRegistrar registrar = + new KafkaConsumerRegistrar( + new TransportConsumerSpec( + KafkaContractHarness.profile(), + delivery -> { + delivery.settlement().acknowledge().toCompletableFuture().join(); + return CompletableFuture.completedFuture(null); + }), + failing, + Runnable::run, + new GracefulShutdownCoordinator(Duration.ofSeconds(30)), + Duration.ofMillis(1)); + + registrar.pollOnce(NOW); + failing.failCommits = true; + + org.assertj.core.api.Assertions.assertThatThrownBy(registrar::close) + .isInstanceOf(org.apache.kafka.clients.consumer.CommitFailedException.class); + assertThat(failing.closed()) + .as("a failed final commit must not leak the consumer/group membership") + .isTrue(); + } + @Test void pauseAndResumeOperateOnTheAssignedPartitions() { KafkaConsumerRegistrar registrar = registrar(this::settleImmediately); @@ -377,7 +464,7 @@ class KafkaConsumerRegistrarTest { consumer.addRecord(record(offset, new RecordHeaders())); } - private ConsumerRecord record(long offset, RecordHeaders headers) { + private static ConsumerRecord record(long offset, RecordHeaders headers) { return new ConsumerRecord<>( TOPIC, 0, @@ -420,6 +507,24 @@ class KafkaConsumerRegistrarTest { handled.add(delivery); return CompletableFuture.completedFuture(null); } + + private static final class CommitFailingConsumer extends MockConsumer { + private boolean failCommits; + + CommitFailingConsumer() { + super("earliest"); + } + + @Override + public synchronized void commitSync( + Map offsets) { + if (failCommits) { + throw new org.apache.kafka.clients.consumer.CommitFailedException("forced final commit"); + } + super.commitSync(offsets); + } + } + } /** Queues handler work so the in-flight ceiling is observable. */ diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaContractHarness.java b/messaging/messaging-kafka/src/testFixtures/java/dev/caskeleton/messaging/kafka/KafkaContractHarness.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaContractHarness.java rename to messaging/messaging-kafka/src/testFixtures/java/dev/caskeleton/messaging/kafka/KafkaContractHarness.java diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaFixtureProfiles.java b/messaging/messaging-kafka/src/testFixtures/java/dev/caskeleton/messaging/kafka/KafkaFixtureProfiles.java similarity index 100% rename from messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaFixtureProfiles.java rename to messaging/messaging-kafka/src/testFixtures/java/dev/caskeleton/messaging/kafka/KafkaFixtureProfiles.java diff --git a/messaging/messaging-nats-experimental/build.gradle b/messaging/messaging-nats-experimental/build.gradle index d635cef..929bf94 100644 --- a/messaging/messaging-nats-experimental/build.gradle +++ b/messaging/messaging-nats-experimental/build.gradle @@ -11,5 +11,4 @@ dependencies { api project(':messaging:messaging-security') api project(':messaging:messaging-admin-api') - implementation libs.jnats } diff --git a/messaging/messaging-nats-experimental/gradle.lockfile b/messaging/messaging-nats-experimental/gradle.lockfile index 03040a9..f5ad1bb 100644 --- a/messaging/messaging-nats-experimental/gradle.lockfile +++ b/messaging/messaging-nats-experimental/gradle.lockfile @@ -35,7 +35,6 @@ io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotatio io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-core:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.nats:jnats:2.26.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath @@ -56,7 +55,6 @@ org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle org.apache.xbean:xbean-reflect:3.7=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.bouncycastle:bcprov-lts8on:2.73.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle diff --git a/messaging/messaging-outbox-jdbc-postgresql/build.gradle b/messaging/messaging-outbox-jdbc-postgresql/build.gradle index 8aabecd..36beb14 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/build.gradle +++ b/messaging/messaging-outbox-jdbc-postgresql/build.gradle @@ -1,7 +1,14 @@ plugins { + id 'ca.auxiliary-source-set' id 'ca.platform-module' } +auxiliarySourceSets { + sourceSet('integrationTest') { + compilesAgainst 'main' + } +} + dependencies { api project(':messaging:messaging-core-api') api project(':messaging:messaging-reliability-api') @@ -19,7 +26,15 @@ dependencies { // Live-database certification. The reliability patterns are claims about transaction // boundaries and uniqueness constraints, and only a real database can settle them. testImplementation project(':messaging:messaging-testkit') - testImplementation 'org.testcontainers:testcontainers-postgresql' - testImplementation 'org.testcontainers:testcontainers-junit-jupiter' - testImplementation 'org.postgresql:postgresql' + integrationTestImplementation 'org.testcontainers:testcontainers-postgresql' + integrationTestImplementation 'org.testcontainers:testcontainers-junit-jupiter' + integrationTestImplementation 'org.postgresql:postgresql' +} + +strictTestLanes { + lane('integrationTest') { + integration() + sourceSet = 'integrationTest' + description = 'Runs outbox and admin-journal contracts against real PostgreSQL.' + } } diff --git a/messaging/messaging-outbox-jdbc-postgresql/gradle.lockfile b/messaging/messaging-outbox-jdbc-postgresql/gradle.lockfile index 93005bc..608e6f7 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/gradle.lockfile +++ b/messaging/messaging-outbox-jdbc-postgresql/gradle.lockfile @@ -1,56 +1,56 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.fasterxml.jackson.core:jackson-annotations:2.21=testCompileClasspath,testRuntimeClasspath -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.docker-java:docker-java-api:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport-zerodep:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor +com.fasterxml.jackson.core:jackson-annotations:2.21=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.github.docker-java:docker-java-api:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport-zerodep:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs com.github.spotbugs:spotbugs:4.10.2=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor +com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.auto:auto-common:1.2.2=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.errorprone:error_prone_annotations:2.41.0=spotbugs com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:guava:33.5.0-jre=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins com.puppycrawl.tools:checkstyle:13.5.0=checkstyle commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-codec:commons-codec:1.19.0=testCompileClasspath,testRuntimeClasspath +commons-codec:commons-codec:1.19.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.20.0=testCompileClasspath,testRuntimeClasspath +commons-io:commons-io:2.20.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-logging:commons-logging:1.3.6=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-core:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor +io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +io.micrometer:micrometer-commons:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-core:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-observation:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +javax.inject:javax.inject:1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.18.1=testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.17.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.java.dev.jna:jna:5.18.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs org.antlr:antlr4-runtime:4.13.2=checkstyle org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-compress:1.28.0=testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-compress:1.28.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.apache.commons:commons-lang3:3.20.0=checkstyle,integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs org.apache.commons:commons-text:1.15.0=spotbugs org.apache.commons:commons-text:1.3=checkstyle org.apache.httpcomponents:httpclient:4.5.13=checkstyle @@ -62,50 +62,50 @@ org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.55.1=testRuntimeClasspath +org.apiguardian:apiguardian-api:1.1.2=integrationTestCompileClasspath,testCompileClasspath +org.assertj:assertj-core:3.27.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.checkerframework:checker-qual:3.55.1=integrationTestRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle org.codehaus.plexus:plexus-utils:3.3.0=checkstyle org.dom4j:dom4j:2.2.0=spotbugs -org.hdrhistogram:HdrHistogram:2.2.2=runtimeClasspath,testRuntimeClasspath +org.hdrhistogram:HdrHistogram:2.2.2=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath org.javassist:javassist:3.28.0-GA=checkstyle -org.jetbrains:annotations:17.0.0=testCompileClasspath,testRuntimeClasspath -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath +org.jetbrains:annotations:17.0.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,integrationTestAnnotationProcessor,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-launcher:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit:junit-bom:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.junit:junit-bom:6.1.0=spotbugs -org.latencyutils:LatencyUtils:2.0.3=runtimeClasspath,testRuntimeClasspath +org.latencyutils:LatencyUtils:2.0.3=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.3.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.ow2.asm:asm-analysis:9.10.1=spotbugs org.ow2.asm:asm-commons:9.10.1=spotbugs org.ow2.asm:asm-tree:9.10.1=spotbugs org.ow2.asm:asm-util:9.10.1=spotbugs org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.postgresql:postgresql:42.7.13=testCompileClasspath,testRuntimeClasspath +org.pcollections:pcollections:4.0.1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +org.postgresql:postgresql:42.7.13=integrationTestCompileClasspath,integrationTestRuntimeClasspath org.reflections:reflections:0.10.2=checkstyle -org.rnorth.duct-tape:duct-tape:1.0.8=testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath +org.rnorth.duct-tape:duct-tape:1.0.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.slf4j:slf4j-api:2.0.18=integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs,spotbugsSlf4j org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-jdbc:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-tx:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-database-commons:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-jdbc:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-junit-jupiter:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-postgresql:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers:2.0.5=testCompileClasspath,testRuntimeClasspath +org.springframework:spring-beans:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-core:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-jdbc:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-tx:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.testcontainers:testcontainers-database-commons:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-jdbc:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-junit-jupiter:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-postgresql:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs empty= diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/AdminOperationJournalPostgresIT.java b/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/AdminOperationJournalPostgresIT.java similarity index 99% rename from messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/AdminOperationJournalPostgresIT.java rename to messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/AdminOperationJournalPostgresIT.java index 5d435b5..7752598 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/AdminOperationJournalPostgresIT.java +++ b/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/AdminOperationJournalPostgresIT.java @@ -67,7 +67,7 @@ class AdminOperationJournalPostgresIT { try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) { statement.execute("DROP TABLE IF EXISTS messaging_admin_operation"); - statement.execute(migration("V3__messaging_admin_operation_journal.sql")); + statement.execute(migration("V1003__messaging_admin_operation_journal.sql")); } journal = new JdbcAdminOperationJournal(dataSource); } diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java b/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java similarity index 99% rename from messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java rename to messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java index eeb5884..cb2d95d 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java +++ b/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java @@ -147,7 +147,7 @@ class OutboxPostgresIT { appendInTransaction(record); repository.leaseBatch(10, Duration.ofSeconds(30), NOW); - repository.markPublished(record.messageId(), NOW); + repository.markPublishedUnfenced(record.messageId(), NOW); assertThat(repository.find(record.messageId()).orElseThrow().status()) .isEqualTo(OutboxStatus.PUBLISHED); @@ -160,7 +160,7 @@ class OutboxPostgresIT { appendInTransaction(record); repository.leaseBatch(10, Duration.ofSeconds(30), NOW); - repository.markFailed(record.messageId(), "INVALID_TOPIC", NOW); + repository.markFailedUnfenced(record.messageId(), "INVALID_TOPIC", NOW); assertThat(repository.leaseBatch(10, Duration.ofSeconds(30), NOW.plusSeconds(60))).isEmpty(); } @@ -197,7 +197,7 @@ class OutboxPostgresIT { OutboxRecord pending = record(); appendInTransaction(published); appendInTransaction(pending); - repository.markPublished(published.messageId(), NOW); + repository.markPublishedUnfenced(published.messageId(), NOW); int removed = repository.purgePublishedBefore(NOW.plusSeconds(1)); diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/main/java/dev/caskeleton/messaging/outbox/JdbcOutboxRepository.java b/messaging/messaging-outbox-jdbc-postgresql/src/main/java/dev/caskeleton/messaging/outbox/JdbcOutboxRepository.java index ec88cba..44a986a 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/src/main/java/dev/caskeleton/messaging/outbox/JdbcOutboxRepository.java +++ b/messaging/messaging-outbox-jdbc-postgresql/src/main/java/dev/caskeleton/messaging/outbox/JdbcOutboxRepository.java @@ -75,7 +75,8 @@ public final class JdbcOutboxRepository implements OutboxRepository { payload, headers, created_at, status, attempts, lease_expires_at, last_failure_code, producer, occurred_at, correlation_id, causation_id, tenant, partition_key, ordering_key, schema_subject, schema_uri, - traceparent, tracestate, baggage"""; + traceparent, tracestate, baggage\ + """; private static final String LEASE = """ @@ -351,7 +352,8 @@ public final class JdbcOutboxRepository implements OutboxRepository { Objects.requireNonNull(lease, "lease must not be null"); String sql = setClause - + "WHERE message_id = ? AND status = 'IN_FLIGHT' AND lease_owner = ? AND lease_token = ?"; + + "WHERE message_id = ? AND status = 'IN_FLIGHT' AND lease_owner = ? AND lease_token =" + + " ?"; return withConnection( connection -> { try (PreparedStatement statement = connection.prepareStatement(sql)) { @@ -400,7 +402,8 @@ public final class JdbcOutboxRepository implements OutboxRepository { Objects.requireNonNull(lease, "lease must not be null"); String sql = setClause - + "WHERE message_id = ? AND status = 'IN_FLIGHT' AND lease_owner = ? AND lease_token = ?"; + + "WHERE message_id = ? AND status = 'IN_FLIGHT' AND lease_owner = ? AND lease_token =" + + " ?"; return withConnection( connection -> { try (PreparedStatement statement = connection.prepareStatement(sql)) { @@ -420,8 +423,7 @@ public final class JdbcOutboxRepository implements OutboxRepository { }); } - @Override - public void markPublished(MessageId messageId, Instant now) { + public void markPublishedUnfenced(MessageId messageId, Instant now) { update( "UPDATE messaging_outbox SET status = 'PUBLISHED', published_at = ?, " + "lease_expires_at = NULL, attempts = attempts + 1 WHERE message_id = ?", @@ -430,8 +432,7 @@ public final class JdbcOutboxRepository implements OutboxRepository { null); } - @Override - public void markAmbiguous(MessageId messageId, String failureCode, Instant now) { + public void markAmbiguousUnfenced(MessageId messageId, String failureCode, Instant now) { // The lease is released rather than held: an ambiguous row must become claimable again so the // relay retries it under the same message id. update( @@ -442,8 +443,7 @@ public final class JdbcOutboxRepository implements OutboxRepository { failureCode); } - @Override - public void markFailed(MessageId messageId, String failureCode, Instant now) { + public void markFailedUnfenced(MessageId messageId, String failureCode, Instant now) { update( "UPDATE messaging_outbox SET status = 'FAILED', lease_expires_at = NULL, " + "last_failure_code = ?, attempts = attempts + 1 WHERE message_id = ?", @@ -452,8 +452,7 @@ public final class JdbcOutboxRepository implements OutboxRepository { failureCode); } - @Override - public void releaseLease(MessageId messageId) { + public void releaseLeaseUnfenced(MessageId messageId) { withConnection( connection -> { try (PreparedStatement statement = diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1__messaging_outbox.sql b/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1001__messaging_outbox.sql similarity index 100% rename from messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1__messaging_outbox.sql rename to messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1001__messaging_outbox.sql diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V2__messaging_outbox_lease_fencing.sql b/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1002__messaging_outbox_lease_fencing.sql similarity index 100% rename from messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V2__messaging_outbox_lease_fencing.sql rename to messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1002__messaging_outbox_lease_fencing.sql diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V3__messaging_admin_operation_journal.sql b/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1003__messaging_admin_operation_journal.sql similarity index 100% rename from messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V3__messaging_admin_operation_journal.sql rename to messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1003__messaging_admin_operation_journal.sql diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V4__messaging_outbox_canonical_metadata.sql b/messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1004__messaging_outbox_canonical_metadata.sql similarity index 100% rename from messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V4__messaging_outbox_canonical_metadata.sql rename to messaging/messaging-outbox-jdbc-postgresql/src/main/resources/db/migration/messaging/V1004__messaging_outbox_canonical_metadata.sql diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxOperationsTest.java b/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxOperationsTest.java index 5425041..f7df5cb 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxOperationsTest.java +++ b/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxOperationsTest.java @@ -64,55 +64,30 @@ class OutboxOperationsTest { @Override public dev.caskeleton.messaging.reliability.OutboxTransitionResult markExhausted( dev.caskeleton.messaging.reliability.OutboxLease lease, String reason, Instant now) { - markFailed(lease.messageId(), reason, now); - return dev.caskeleton.messaging.reliability.OutboxTransitionResult.APPLIED; + throw new UnsupportedOperationException(); } @Override public dev.caskeleton.messaging.reliability.OutboxTransitionResult markPublished( dev.caskeleton.messaging.reliability.OutboxLease lease, Instant now) { - markPublished(lease.messageId(), now); - return dev.caskeleton.messaging.reliability.OutboxTransitionResult.APPLIED; + throw new UnsupportedOperationException(); } @Override public dev.caskeleton.messaging.reliability.OutboxTransitionResult markAmbiguous( dev.caskeleton.messaging.reliability.OutboxLease lease, String failureCode, Instant now) { - markAmbiguous(lease.messageId(), failureCode, now); - return dev.caskeleton.messaging.reliability.OutboxTransitionResult.APPLIED; + throw new UnsupportedOperationException(); } @Override public dev.caskeleton.messaging.reliability.OutboxTransitionResult markFailed( dev.caskeleton.messaging.reliability.OutboxLease lease, String failureCode, Instant now) { - markFailed(lease.messageId(), failureCode, now); - return dev.caskeleton.messaging.reliability.OutboxTransitionResult.APPLIED; + throw new UnsupportedOperationException(); } @Override public dev.caskeleton.messaging.reliability.OutboxTransitionResult releaseLease( dev.caskeleton.messaging.reliability.OutboxLease lease) { - releaseLease(lease.messageId()); - return dev.caskeleton.messaging.reliability.OutboxTransitionResult.APPLIED; - } - - @Override - public void markPublished(MessageId messageId, Instant now) { - throw new UnsupportedOperationException(); - } - - @Override - public void markAmbiguous(MessageId messageId, String failureCode, Instant now) { - throw new UnsupportedOperationException(); - } - - @Override - public void markFailed(MessageId messageId, String failureCode, Instant now) { - throw new UnsupportedOperationException(); - } - - @Override - public void releaseLease(MessageId messageId) { throw new UnsupportedOperationException(); } diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxRelayTest.java b/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxRelayTest.java index 62bc74f..471ba56 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxRelayTest.java +++ b/messaging/messaging-outbox-jdbc-postgresql/src/test/java/dev/caskeleton/messaging/outbox/OutboxRelayTest.java @@ -305,7 +305,7 @@ final class InMemoryOutboxRepository implements OutboxRepository { boolean waiting = nextAttempt != null && now.isBefore(nextAttempt); if (waiting || lease.record().attempts() >= maxAttempts) { // Put it back exactly as the SQL predicate would have left it: unclaimed. - releaseLease(lease.messageId()); + releaseLeaseUnfenced(lease.messageId()); continue; } claimed.add(lease); @@ -349,7 +349,7 @@ final class InMemoryOutboxRepository implements OutboxRepository { if (!owns(lease)) { return OutboxTransitionResult.STALE_LEASE; } - markAmbiguous(lease.messageId(), failureCode, now); + markAmbiguousUnfenced(lease.messageId(), failureCode); owners.remove(lease.messageId()); return OutboxTransitionResult.APPLIED; } @@ -359,7 +359,7 @@ final class InMemoryOutboxRepository implements OutboxRepository { if (!owns(lease)) { return OutboxTransitionResult.STALE_LEASE; } - markFailed(lease.messageId(), failureCode, now); + markFailedUnfenced(lease.messageId(), failureCode); owners.remove(lease.messageId()); return OutboxTransitionResult.APPLIED; } @@ -369,29 +369,21 @@ final class InMemoryOutboxRepository implements OutboxRepository { if (!owns(lease)) { return OutboxTransitionResult.STALE_LEASE; } - releaseLease(lease.messageId()); + releaseLeaseUnfenced(lease.messageId()); owners.remove(lease.messageId()); return OutboxTransitionResult.APPLIED; } - @Override - public void markPublished(MessageId messageId, Instant now) { - transition(messageId, OutboxStatus.PUBLISHED, Optional.empty()); - } - - @Override - public void markAmbiguous(MessageId messageId, String failureCode, Instant now) { + private void markAmbiguousUnfenced(MessageId messageId, String failureCode) { transition(messageId, OutboxStatus.AMBIGUOUS, Optional.of(failureCode)); leases.remove(messageId); } - @Override - public void markFailed(MessageId messageId, String failureCode, Instant now) { + private void markFailedUnfenced(MessageId messageId, String failureCode) { transition(messageId, OutboxStatus.FAILED, Optional.of(failureCode)); } - @Override - public void releaseLease(MessageId messageId) { + private void releaseLeaseUnfenced(MessageId messageId) { leases.remove(messageId); } diff --git a/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/DestinationProfileValidator.java b/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/DestinationProfileValidator.java index bcd4728..4757611 100644 --- a/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/DestinationProfileValidator.java +++ b/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/DestinationProfileValidator.java @@ -71,6 +71,13 @@ public final class DestinationProfileValidator { throw new IllegalArgumentException( "at-least-once delivery requires a publish confirmation for " + profile.name().value()); } + if (profile.deliveryGuarantee() == DeliveryGuarantee.AT_LEAST_ONCE + && !profile.deadLetter().enabled()) { + throw new IllegalArgumentException( + "at-least-once delivery requires a dead letter destination so a failed delivery has " + + "an executable terminal path: " + + profile.name().value()); + } if (profile.production() && profile.topologyAutoCreate()) { throw new IllegalArgumentException( "a production profile must not auto-create topology: " + profile.name().value()); diff --git a/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/MessagingAdmissionController.java b/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/MessagingAdmissionController.java index 108e743..4b2cc98 100644 --- a/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/MessagingAdmissionController.java +++ b/messaging/messaging-policy/src/main/java/dev/caskeleton/messaging/policy/MessagingAdmissionController.java @@ -169,16 +169,20 @@ public final class MessagingAdmissionController { } private boolean reserve(String destination) { - AtomicInteger counter = perDestination.computeIfAbsent(destination, key -> new AtomicInteger()); - while (true) { - int current = counter.get(); - if (current >= perDestinationLimit) { - return false; - } - if (counter.compareAndSet(current, current + 1)) { - return true; - } - } + java.util.concurrent.atomic.AtomicBoolean reserved = + new java.util.concurrent.atomic.AtomicBoolean(); + perDestination.compute( + destination, + (key, existing) -> { + AtomicInteger counter = existing == null ? new AtomicInteger() : existing; + if (counter.get() >= perDestinationLimit) { + return counter; + } + counter.incrementAndGet(); + reserved.set(true); + return counter; + }); + return reserved.get(); } /** @@ -187,14 +191,18 @@ public final class MessagingAdmissionController { * @return true when this call actually released a slot the destination was holding */ private boolean release(String destination) { - AtomicInteger counter = perDestination.get(destination); - if (counter == null) { - return false; - } - int before = counter.getAndUpdate(current -> current > 0 ? current - 1 : current); - // Drop the entry at zero, atomically, so the map does not accumulate one counter per - // destination ever published to for the life of the process. - perDestination.computeIfPresent(destination, (key, value) -> value.get() == 0 ? null : value); - return before > 0; + java.util.concurrent.atomic.AtomicBoolean released = + new java.util.concurrent.atomic.AtomicBoolean(); + perDestination.computeIfPresent( + destination, + (key, counter) -> { + if (counter.get() <= 0) { + return null; + } + int remaining = counter.decrementAndGet(); + released.set(true); + return remaining == 0 ? null : counter; + }); + return released.get(); } } diff --git a/messaging/messaging-policy/src/test/java/dev/caskeleton/messaging/policy/DestinationProfileValidatorTest.java b/messaging/messaging-policy/src/test/java/dev/caskeleton/messaging/policy/DestinationProfileValidatorTest.java index 5bc613b..f2c16a9 100644 --- a/messaging/messaging-policy/src/test/java/dev/caskeleton/messaging/policy/DestinationProfileValidatorTest.java +++ b/messaging/messaging-policy/src/test/java/dev/caskeleton/messaging/policy/DestinationProfileValidatorTest.java @@ -88,6 +88,15 @@ class DestinationProfileValidatorTest { .hasMessageContaining("confirmation"); } + @Test + void atLeastOnceRequiresADeadLetterDestinationEvenWhenRetriesAreDisabled() { + DestinationProfile profile = DestinationProfileFixtures.atLeastOnceWithoutDeadLetter(); + + assertThatThrownBy(() -> validator.validate(profile)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("dead letter destination"); + } + @Test void aProductionProfileCannotAutoCreateTopology() { DestinationProfile profile = DestinationProfileFixtures.productionWithAutoCreate(); @@ -103,7 +112,7 @@ class DestinationProfileValidatorTest { assertThatThrownBy(() -> validator.validate(profile)) .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("park"); + .hasMessageContaining("dead letter destination"); } @Test @@ -177,7 +186,7 @@ final class DestinationProfileFixtures { ProducerPolicy.defaults(), ConsumerPolicy.defaults("order-projection"), RetryPolicy.none(), - DeadLetterPolicy.disabled(), + DeadLetterPolicy.to(new DestinationName("order-events-dlq")), PayloadPolicy.defaults(), CapabilityTier.M1, false, @@ -392,6 +401,28 @@ final class DestinationProfileFixtures { base.topologyAutoCreate()); } + static DestinationProfile atLeastOnceWithoutDeadLetter() { + DestinationProfile base = base(); + return new DestinationProfile( + base.name(), + base.broker(), + base.kind(), + base.physical(), + base.schema(), + DeliveryGuarantee.AT_LEAST_ONCE, + base.orderingScope(), + base.externalSideEffectGuarantee(), + base.producer(), + base.consumer(), + RetryPolicy.none(), + DeadLetterPolicy.disabled(), + base.payload(), + base.tier(), + base.production(), + base.keyResolverConfigured(), + base.topologyAutoCreate()); + } + static DestinationProfile atMostOnceWithoutDeadLetter() { DestinationProfile base = base(); return new DestinationProfile( @@ -414,6 +445,28 @@ final class DestinationProfileFixtures { base.topologyAutoCreate()); } + static DestinationProfile parking(String name) { + DestinationProfile base = atMostOnceWithoutDeadLetter(); + return new DestinationProfile( + new DestinationName(name), + base.broker(), + base.kind(), + base.physical(), + base.schema(), + base.deliveryGuarantee(), + base.orderingScope(), + base.externalSideEffectGuarantee(), + base.producer(), + base.consumer(), + base.retry(), + base.deadLetter(), + base.payload(), + base.tier(), + base.production(), + base.keyResolverConfigured(), + base.topologyAutoCreate()); + } + static RetryPolicy retryTo(String destination) { return new RetryPolicy( RetryMode.RETRY_DESTINATION, @@ -432,8 +485,8 @@ final class DestinationProfileFixtures { return List.of( named("alpha", retryTo("beta"), DeadLetterPolicy.to(new DestinationName("alpha-dlq"))), named("beta", retryTo("alpha"), DeadLetterPolicy.to(new DestinationName("beta-dlq"))), - named("alpha-dlq", RetryPolicy.none(), DeadLetterPolicy.disabled()), - named("beta-dlq", RetryPolicy.none(), DeadLetterPolicy.disabled())); + parking("alpha-dlq"), + parking("beta-dlq")); } /** @@ -449,7 +502,7 @@ final class DestinationProfileFixtures { return List.of( named("alpha", retryTo("beta"), DeadLetterPolicy.to(new DestinationName("alpha-dlq"))), named("beta", RetryPolicy.none(), DeadLetterPolicy.to(new DestinationName("alpha"))), - named("alpha-dlq", RetryPolicy.none(), DeadLetterPolicy.disabled())); + parking("alpha-dlq")); } /** Two destinations dead-lettering into the same place: a diamond, not a cycle. */ @@ -457,12 +510,12 @@ final class DestinationProfileFixtures { return List.of( named("alpha", RetryPolicy.none(), DeadLetterPolicy.to(new DestinationName("shared-dlq"))), named("beta", RetryPolicy.none(), DeadLetterPolicy.to(new DestinationName("shared-dlq"))), - named("shared-dlq", RetryPolicy.none(), DeadLetterPolicy.disabled())); + parking("shared-dlq")); } static List danglingRetryDestination() { return List.of( named("alpha", retryTo("missing"), DeadLetterPolicy.to(new DestinationName("alpha-dlq"))), - named("alpha-dlq", RetryPolicy.none(), DeadLetterPolicy.disabled())); + parking("alpha-dlq")); } } diff --git a/messaging/messaging-pulsar-experimental/build.gradle b/messaging/messaging-pulsar-experimental/build.gradle index c98d34a..929bf94 100644 --- a/messaging/messaging-pulsar-experimental/build.gradle +++ b/messaging/messaging-pulsar-experimental/build.gradle @@ -11,5 +11,4 @@ dependencies { api project(':messaging:messaging-security') api project(':messaging:messaging-admin-api') - implementation libs.pulsar.client } diff --git a/messaging/messaging-pulsar-experimental/gradle.lockfile b/messaging/messaging-pulsar-experimental/gradle.lockfile index 86f863d..f5ad1bb 100644 --- a/messaging/messaging-pulsar-experimental/gradle.lockfile +++ b/messaging/messaging-pulsar-experimental/gradle.lockfile @@ -1,7 +1,6 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.fasterxml.jackson.core:jackson-annotations:2.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs @@ -36,12 +35,7 @@ io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotatio io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-core:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.opentelemetry:opentelemetry-api-incubator:1.45.0-alpha=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.opentelemetry:opentelemetry-api:1.55.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.opentelemetry:opentelemetry-common:1.55.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.opentelemetry:opentelemetry-context:1.55.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -javax.validation:validation-api:1.1.0.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath jaxen:jaxen:2.0.6=spotbugs net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs @@ -58,17 +52,9 @@ org.apache.maven.doxia:doxia-core:1.12.0=checkstyle org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.pulsar:bouncy-castle-bc:4.1.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.pulsar:pulsar-client-admin-api:4.1.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.pulsar:pulsar-client-api:4.1.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.pulsar:pulsar-client:4.0.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.xbean:xbean-reflect:3.7=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.bouncycastle:bcpkix-jdk18on:1.81=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.bouncycastle:bcprov-ext-jdk18on:1.78.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.bouncycastle:bcprov-jdk18on:1.81.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.bouncycastle:bcutil-jdk18on:1.81.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle @@ -96,7 +82,7 @@ org.ow2.asm:asm-util:9.10.1=spotbugs org.ow2.asm:asm:9.10.1=spotbugs org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=compileClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath +org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs diff --git a/messaging/messaging-rabbit/build.gradle b/messaging/messaging-rabbit/build.gradle index b45f5fb..f346996 100644 --- a/messaging/messaging-rabbit/build.gradle +++ b/messaging/messaging-rabbit/build.gradle @@ -1,7 +1,15 @@ plugins { + id 'java-test-fixtures' + id 'ca.auxiliary-source-set' id 'ca.jmh-benchmarks' } +auxiliarySourceSets { + sourceSet('integrationTest') { + compilesAgainst 'main', 'testFixtures' + } +} + dependencies { api project(':messaging:messaging-core-api') api project(':messaging:messaging-schema-api') @@ -22,6 +30,14 @@ dependencies { // Live-broker certification. The confirm-and-return ordering the adapter depends on is a // property of AMQP, and only a real broker exhibits it. - testImplementation 'org.testcontainers:testcontainers-rabbitmq' - testImplementation 'org.testcontainers:testcontainers-junit-jupiter' + integrationTestImplementation 'org.testcontainers:testcontainers-rabbitmq' + integrationTestImplementation 'org.testcontainers:testcontainers-junit-jupiter' +} + +strictTestLanes { + lane('integrationTest') { + integration() + sourceSet = 'integrationTest' + description = 'Runs RabbitMQ broker integration contracts against a real container.' + } } diff --git a/messaging/messaging-rabbit/gradle.lockfile b/messaging/messaging-rabbit/gradle.lockfile index 703374a..e5000c2 100644 --- a/messaging/messaging-rabbit/gradle.lockfile +++ b/messaging/messaging-rabbit/gradle.lockfile @@ -1,69 +1,69 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.fasterxml.jackson.core:jackson-annotations:2.21=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.github.docker-java:docker-java-api:3.7.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport-zerodep:3.7.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport:3.7.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.fasterxml.jackson.core:jackson-annotations:2.21=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.github.docker-java:docker-java-api:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport-zerodep:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs com.github.spotbugs:spotbugs:4.10.2=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.auto:auto-common:1.2.2=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.google.errorprone:error_prone_annotations:2.41.0=spotbugs com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,jmhAnnotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.guava:guava:33.5.0-jre=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,jmhAnnotationProcessor,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,jmhAnnotationProcessor,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -com.rabbitmq:amqp-client:5.27.1=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.rabbitmq:amqp-client:5.27.1=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-codec:commons-codec:1.19.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-codec:commons-codec:1.19.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.20.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-io:commons-io:2.20.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-logging:commons-logging:1.3.6=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor -io.micrometer:micrometer-commons:1.16.7=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-core:1.16.7=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-observation:1.16.7=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-buffer:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-base:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-compression:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-marshalling:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-protobuf:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-common:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-handler:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-resolver:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-transport-native-unix-common:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-transport:4.2.17.Final=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor +io.micrometer:micrometer-commons:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-core:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-observation:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-buffer:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-codec-base:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-codec-compression:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-codec-marshalling:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-codec-protobuf:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-codec:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-common:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-handler:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-resolver:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-transport-native-unix-common:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +io.netty:netty-transport:4.2.17.Final=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +javax.inject:javax.inject:1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.18.1=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.17.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.java.dev.jna:jna:5.18.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath net.sf.jopt-simple:jopt-simple:5.0.4=jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs org.antlr:antlr4-runtime:4.13.2=checkstyle org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-compress:1.28.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-lang3:3.20.0=checkstyle,jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-compress:1.28.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.apache.commons:commons-lang3:3.20.0=checkstyle,integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs org.apache.commons:commons-math3:3.6.1=jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath org.apache.commons:commons-text:1.15.0=spotbugs org.apache.commons:commons-text:1.3=checkstyle @@ -76,53 +76,53 @@ org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=jmhCompileClasspath,testCompileClasspath -org.assertj:assertj-core:3.27.7=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apiguardian:apiguardian-api:1.1.2=integrationTestCompileClasspath,jmhCompileClasspath,testCompileClasspath +org.assertj:assertj-core:3.27.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle org.codehaus.plexus:plexus-utils:3.3.0=checkstyle org.dom4j:dom4j:2.2.0=spotbugs -org.hdrhistogram:HdrHistogram:2.2.2=jmhRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +org.hdrhistogram:HdrHistogram:2.2.2=integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.javassist:javassist:3.28.0-GA=checkstyle -org.jetbrains:annotations:17.0.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=jmhRuntimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=jmhRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=jmhRuntimeClasspath,testRuntimeClasspath -org.junit:junit-bom:6.0.3=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jetbrains:annotations:17.0.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,integrationTestAnnotationProcessor,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testFixturesAnnotationProcessor,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-launcher:6.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,testRuntimeClasspath +org.junit:junit-bom:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.junit:junit-bom:6.1.0=spotbugs -org.latencyutils:LatencyUtils:2.0.3=jmhRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +org.latencyutils:LatencyUtils:2.0.3=integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.mockito:mockito-core:5.20.0=mockitoAgent org.openjdk.jmh:jmh-core:1.37=jmhAnnotationProcessor,jmhCompileClasspath,jmhRuntimeClasspath org.openjdk.jmh:jmh-generator-annprocess:1.37=jmhAnnotationProcessor -org.opentest4j:opentest4j:1.3.0=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.3.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.ow2.asm:asm-analysis:9.10.1=spotbugs org.ow2.asm:asm-commons:9.10.1=spotbugs org.ow2.asm:asm-tree:9.10.1=spotbugs org.ow2.asm:asm-util:9.10.1=spotbugs org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor +org.pcollections:pcollections:4.0.1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor org.reflections:reflections:0.10.2=checkstyle -org.rnorth.duct-tape:duct-tape:1.0.8=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:2.0.18=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath +org.rnorth.duct-tape:duct-tape:1.0.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.slf4j:slf4j-api:2.0.18=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework.amqp:spring-amqp:4.0.5=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework.amqp:spring-rabbit:4.0.5=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-aop:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-beans:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-context:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-expression:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-messaging:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-tx:7.0.9=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-junit-jupiter:2.0.5=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-rabbitmq:2.0.5=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers:2.0.5=jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.amqp:spring-amqp:4.0.5=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework.amqp:spring-rabbit:4.0.5=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-aop:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-beans:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-context:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-core:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-expression:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-messaging:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-tx:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath +org.testcontainers:testcontainers-junit-jupiter:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-rabbitmq:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs empty= diff --git a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitBrokerIT.java b/messaging/messaging-rabbit/src/integrationTest/java/dev/caskeleton/messaging/rabbit/RabbitBrokerIT.java similarity index 100% rename from messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitBrokerIT.java rename to messaging/messaging-rabbit/src/integrationTest/java/dev/caskeleton/messaging/rabbit/RabbitBrokerIT.java diff --git a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitFixtureProfiles.java b/messaging/messaging-rabbit/src/integrationTest/java/dev/caskeleton/messaging/rabbit/RabbitFixtureProfiles.java similarity index 100% rename from messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitFixtureProfiles.java rename to messaging/messaging-rabbit/src/integrationTest/java/dev/caskeleton/messaging/rabbit/RabbitFixtureProfiles.java diff --git a/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitMessagingTransport.java b/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitMessagingTransport.java index 89fe488..b6d5862 100644 --- a/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitMessagingTransport.java +++ b/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitMessagingTransport.java @@ -20,6 +20,9 @@ import java.util.Objects; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; @@ -48,6 +51,8 @@ public final class RabbitMessagingTransport implements MessagingTransport { private final RabbitPublishMapper mapper; private final RabbitConfirmCoordinator coordinator; private final Function consumerFactory; + private final Duration confirmTimeout; + private final ScheduledExecutorService confirmTimeouts; private final AtomicBoolean closed = new AtomicBoolean(); /** @@ -59,6 +64,12 @@ public final class RabbitMessagingTransport implements MessagingTransport { */ public RabbitMessagingTransport( String brokerName, long generation, RabbitChannelPublisher channel) { + this(brokerName, generation, channel, Duration.ofSeconds(5)); + } + + /** Creates a publish-only transport with an explicit confirm timeout. */ + public RabbitMessagingTransport( + String brokerName, long generation, RabbitChannelPublisher channel, Duration confirmTimeout) { this( brokerName, generation, @@ -67,7 +78,8 @@ public final class RabbitMessagingTransport implements MessagingTransport { throw new MessagingCapabilityUnavailableException( "RABBIT_CONSUMER_NOT_CONFIGURED", "this Rabbit transport was created without a consumer factory"); - }); + }, + confirmTimeout); } /** @@ -83,12 +95,33 @@ public final class RabbitMessagingTransport implements MessagingTransport { long generation, RabbitChannelPublisher channel, Function consumerFactory) { + this(brokerName, generation, channel, consumerFactory, Duration.ofSeconds(5)); + } + + /** Creates a transport with explicit consumer factory and confirm deadline. */ + public RabbitMessagingTransport( + String brokerName, + long generation, + RabbitChannelPublisher channel, + Function consumerFactory, + Duration confirmTimeout) { this.brokerName = Objects.requireNonNull(brokerName, "brokerName must not be null"); this.generation = generation; this.channel = Objects.requireNonNull(channel, "channel must not be null"); this.consumerFactory = Objects.requireNonNull(consumerFactory, "consumerFactory is required"); + this.confirmTimeout = Objects.requireNonNull(confirmTimeout, "confirmTimeout must not be null"); + if (confirmTimeout.isNegative() || confirmTimeout.isZero()) { + throw new IllegalArgumentException("confirmTimeout must be positive"); + } this.mapper = new RabbitPublishMapper(); this.coordinator = new RabbitConfirmCoordinator(); + this.confirmTimeouts = + Executors.newSingleThreadScheduledExecutor( + runnable -> { + Thread thread = new Thread(runnable, "messaging-rabbit-confirm-timeouts"); + thread.setDaemon(true); + return thread; + }); } @Override @@ -117,6 +150,12 @@ public final class RabbitMessagingTransport implements MessagingTransport { coordinator .awaiting(sequence, exchange, routingKey, request.profile().producer().confirmation()) .thenApply(TransportPublishResult::new); + var timeout = + confirmTimeouts.schedule( + () -> coordinator.timedOut(sequence, confirmTimeout), + confirmTimeout.toNanos(), + TimeUnit.NANOSECONDS); + pending.whenComplete((result, failure) -> timeout.cancel(false)); try { channel.publish(sequence, exchange, routingKey, mapper.toMessage(request), true); @@ -216,6 +255,7 @@ public final class RabbitMessagingTransport implements MessagingTransport { // Drain what is still waiting. Leaving the stages pending hangs every caller holding one, and // a closed channel will never deliver their confirms. coordinator.channelClosed(Duration.ZERO); + confirmTimeouts.shutdownNow(); channel.close(); } diff --git a/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitPublishFailureClassifier.java b/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitPublishFailureClassifier.java index 4fb3cea..c9408b9 100644 --- a/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitPublishFailureClassifier.java +++ b/messaging/messaging-rabbit/src/main/java/dev/caskeleton/messaging/rabbit/RabbitPublishFailureClassifier.java @@ -91,19 +91,35 @@ public final class RabbitPublishFailureClassifier { } private static FailureCategory categoryOf(Throwable cause) { + if (cause instanceof com.rabbitmq.client.PossibleAuthenticationFailureException) { + return FailureCategory.AUTHENTICATION; + } + if (cause instanceof com.rabbitmq.client.ShutdownSignalException shutdown) { + int replyCode = replyCode(shutdown.getReason()); + if (replyCode == 403) { + return FailureCategory.AUTHORIZATION; + } + if (replyCode >= 500) { + return FailureCategory.TRANSIENT_INFRASTRUCTURE; + } + return FailureCategory.PERMANENT_BUSINESS; + } if (cause instanceof IOException) { return FailureCategory.TRANSIENT_INFRASTRUCTURE; } - String name = name(cause); - if (name.contains("Authentication")) { - return FailureCategory.AUTHENTICATION; - } - if (name.contains("Authorization") || name.contains("AccessRefused")) { - return FailureCategory.AUTHORIZATION; - } return FailureCategory.PERMANENT_BUSINESS; } + private static int replyCode(com.rabbitmq.client.Method reason) { + if (reason instanceof com.rabbitmq.client.AMQP.Channel.Close close) { + return close.getReplyCode(); + } + if (reason instanceof com.rabbitmq.client.AMQP.Connection.Close close) { + return close.getReplyCode(); + } + return -1; + } + private static Throwable unwrap(Throwable error) { if (error instanceof java.util.concurrent.CompletionException && error.getCause() != null) { return error.getCause(); diff --git a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitProfileValidatorTest.java b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitProfileValidatorTest.java index 5419398..ba0f14f 100644 --- a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitProfileValidatorTest.java +++ b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitProfileValidatorTest.java @@ -3,26 +3,6 @@ package dev.caskeleton.messaging.rabbit; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import dev.caskeleton.messaging.api.ContentType; -import dev.caskeleton.messaging.api.MessageType; -import dev.caskeleton.messaging.api.delivery.DeliveryGuarantee; -import dev.caskeleton.messaging.api.delivery.ExternalSideEffectGuarantee; -import dev.caskeleton.messaging.api.delivery.OrderingScope; -import dev.caskeleton.messaging.api.destination.DestinationKind; -import dev.caskeleton.messaging.api.destination.DestinationName; -import dev.caskeleton.messaging.policy.CapabilityTier; -import dev.caskeleton.messaging.policy.ConsumerPolicy; -import dev.caskeleton.messaging.policy.DeadLetterPolicy; -import dev.caskeleton.messaging.policy.DestinationProfile; -import dev.caskeleton.messaging.policy.PayloadPolicy; -import dev.caskeleton.messaging.policy.PhysicalDestination; -import dev.caskeleton.messaging.policy.ProducerPolicy; -import dev.caskeleton.messaging.policy.RetryPolicy; -import dev.caskeleton.messaging.policy.SchemaPolicy; -import dev.caskeleton.messaging.schema.SchemaCompatibility; -import java.time.Duration; -import java.util.List; -import java.util.Set; import org.junit.jupiter.api.Test; class RabbitProfileValidatorTest { @@ -86,99 +66,3 @@ class RabbitProfileValidatorTest { .doesNotThrowAnyException(); } } - -/** Builds RabbitMQ profiles for validator tests. */ -final class RabbitProfileFixtures { - - private RabbitProfileFixtures() {} - - static RabbitBrokerProfile stable() { - return new RabbitBrokerProfile( - "rabbit-primary", - true, - false, - List.of("localhost:5672"), - true, - true, - true, - Duration.ofSeconds(5), - false, - 16, - true, - true, - true); - } - - static RabbitBrokerProfile withoutConfirms() { - return copy(stable(), false, true, true, false, true, false, true); - } - - static RabbitBrokerProfile withoutReturns() { - return copy(stable(), true, false, true, false, true, false, true); - } - - static RabbitBrokerProfile withoutMandatory() { - return copy(stable(), true, true, false, false, true, false, true); - } - - static RabbitBrokerProfile withAutoAck() { - return copy(stable(), true, true, true, true, true, false, true); - } - - static RabbitBrokerProfile withoutQuorumQueues() { - return copy(stable(), true, true, true, false, false, false, true); - } - - static RabbitBrokerProfile productionWithoutTls() { - return copy(stable(), true, true, true, false, true, true, false); - } - - private static RabbitBrokerProfile copy( - RabbitBrokerProfile base, - boolean confirms, - boolean returns, - boolean mandatory, - boolean autoAck, - boolean quorumQueues, - boolean production, - boolean tlsEnabled) { - return new RabbitBrokerProfile( - base.broker(), - base.stable(), - production, - base.addresses(), - confirms, - returns, - mandatory, - base.confirmTimeout(), - autoAck, - base.prefetch(), - quorumQueues, - tlsEnabled, - base.authenticationEnabled()); - } - - static DestinationProfile workQueueDestination() { - return new DestinationProfile( - new DestinationName("email-work"), - "rabbit-primary", - DestinationKind.WORK_QUEUE, - PhysicalDestination.rabbitQueue("notification.work", "email", "notification.email.q"), - new SchemaPolicy( - ContentType.JSON, - SchemaCompatibility.BACKWARD, - Set.of(new MessageType("email.requested"))), - DeliveryGuarantee.AT_LEAST_ONCE, - OrderingScope.NONE, - ExternalSideEffectGuarantee.IDEMPOTENCY_REQUIRED, - ProducerPolicy.defaults(), - ConsumerPolicy.defaults("notification"), - RetryPolicy.none(), - DeadLetterPolicy.to(new DestinationName("email-work-dlq")), - PayloadPolicy.defaults(), - CapabilityTier.M1, - false, - false, - false); - } -} diff --git a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitRuntimeTest.java b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitRuntimeTest.java index b45e35e..903beae 100644 --- a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitRuntimeTest.java +++ b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitRuntimeTest.java @@ -88,6 +88,38 @@ class RabbitRuntimeTest { assertThat(result.routingOutcome()).isEqualTo(RoutingOutcome.UNROUTABLE); } + @Test + void aMissingConfirmExpiresWithoutAnExternalTimeoutCallback() throws Exception { + try (RabbitMessagingTransport timed = + new RabbitMessagingTransport( + "rabbit-primary", + 1, + new RabbitChannelPublisher() { + @Override + public long nextPublishSequence() { + return sequence.incrementAndGet(); + } + + @Override + public void publish( + long sequenceNumber, + String exchange, + String routingKey, + Message message, + boolean mandatory) { + published.add(message); + } + }, + Duration.ofMillis(20))) { + CompletionStage stage = timed.publish(request()); + + var result = + stage.toCompletableFuture().get(1, java.util.concurrent.TimeUnit.SECONDS).result(); + assertThat(result.completion()).isEqualTo(PublishCompletion.AMBIGUOUS); + assertThat(timed.pendingConfirms()).isZero(); + } + } + @Test void aMissingConfirmIsAmbiguous() { RabbitMessagingTransport transport = transport(); diff --git a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java index 040a8df..678615c 100644 --- a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java +++ b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java @@ -122,6 +122,39 @@ class RabbitTopologyAndBatchTest { .isEqualTo(TransmissionEvidence.MAY_HAVE_BEEN_TRANSMITTED); } + @Test + void authenticationFailureUsesTheTypedRabbitSignal() { + PublishResult result = + new RabbitPublishFailureClassifier() + .classify( + new com.rabbitmq.client.AuthenticationFailureException("bad credentials"), + false, + Duration.ofMillis(3)); + + assertThat(result.failure()).hasValueSatisfying( + failure -> assertThat(failure.category()).isEqualTo( + dev.caskeleton.messaging.api.error.FailureCategory.AUTHENTICATION)); + } + + @Test + void accessRefusedReplyCodeIsAuthorizationRatherThanBusinessRejection() { + com.rabbitmq.client.ShutdownSignalException accessRefused = + new com.rabbitmq.client.ShutdownSignalException( + false, + false, + new com.rabbitmq.client.impl.AMQImpl.Channel.Close( + 403, "ACCESS_REFUSED", 60, 40), + null); + + PublishResult result = + new RabbitPublishFailureClassifier() + .classify(accessRefused, false, Duration.ofMillis(3)); + + assertThat(result.failure()).hasValueSatisfying( + failure -> assertThat(failure.category()).isEqualTo( + dev.caskeleton.messaging.api.error.FailureCategory.AUTHORIZATION)); + } + @Test void aNackIsRejectedButStillCountsAsTransmitted() { PublishResult result = new RabbitPublishFailureClassifier().nacked(Duration.ofMillis(3)); diff --git a/messaging/messaging-rabbit/src/testFixtures/java/dev/caskeleton/messaging/rabbit/RabbitProfileFixtures.java b/messaging/messaging-rabbit/src/testFixtures/java/dev/caskeleton/messaging/rabbit/RabbitProfileFixtures.java new file mode 100644 index 0000000..e505cd2 --- /dev/null +++ b/messaging/messaging-rabbit/src/testFixtures/java/dev/caskeleton/messaging/rabbit/RabbitProfileFixtures.java @@ -0,0 +1,118 @@ +package dev.caskeleton.messaging.rabbit; + +import dev.caskeleton.messaging.api.ContentType; +import dev.caskeleton.messaging.api.MessageType; +import dev.caskeleton.messaging.api.delivery.DeliveryGuarantee; +import dev.caskeleton.messaging.api.delivery.ExternalSideEffectGuarantee; +import dev.caskeleton.messaging.api.delivery.OrderingScope; +import dev.caskeleton.messaging.api.destination.DestinationKind; +import dev.caskeleton.messaging.api.destination.DestinationName; +import dev.caskeleton.messaging.policy.CapabilityTier; +import dev.caskeleton.messaging.policy.ConsumerPolicy; +import dev.caskeleton.messaging.policy.DeadLetterPolicy; +import dev.caskeleton.messaging.policy.DestinationProfile; +import dev.caskeleton.messaging.policy.PayloadPolicy; +import dev.caskeleton.messaging.policy.PhysicalDestination; +import dev.caskeleton.messaging.policy.ProducerPolicy; +import dev.caskeleton.messaging.policy.RetryPolicy; +import dev.caskeleton.messaging.policy.SchemaPolicy; +import dev.caskeleton.messaging.schema.SchemaCompatibility; +import java.time.Duration; +import java.util.List; +import java.util.Set; + +/** Builds RabbitMQ profiles for validator tests. */ +final class RabbitProfileFixtures { + + private RabbitProfileFixtures() {} + + static RabbitBrokerProfile stable() { + return new RabbitBrokerProfile( + "rabbit-primary", + true, + false, + List.of("localhost:5672"), + true, + true, + true, + Duration.ofSeconds(5), + false, + 16, + true, + true, + true); + } + + static RabbitBrokerProfile withoutConfirms() { + return copy(stable(), false, true, true, false, true, false, true); + } + + static RabbitBrokerProfile withoutReturns() { + return copy(stable(), true, false, true, false, true, false, true); + } + + static RabbitBrokerProfile withoutMandatory() { + return copy(stable(), true, true, false, false, true, false, true); + } + + static RabbitBrokerProfile withAutoAck() { + return copy(stable(), true, true, true, true, true, false, true); + } + + static RabbitBrokerProfile withoutQuorumQueues() { + return copy(stable(), true, true, true, false, false, false, true); + } + + static RabbitBrokerProfile productionWithoutTls() { + return copy(stable(), true, true, true, false, true, true, false); + } + + private static RabbitBrokerProfile copy( + RabbitBrokerProfile base, + boolean confirms, + boolean returns, + boolean mandatory, + boolean autoAck, + boolean quorumQueues, + boolean production, + boolean tlsEnabled) { + return new RabbitBrokerProfile( + base.broker(), + base.stable(), + production, + base.addresses(), + confirms, + returns, + mandatory, + base.confirmTimeout(), + autoAck, + base.prefetch(), + quorumQueues, + tlsEnabled, + base.authenticationEnabled()); + } + + static DestinationProfile workQueueDestination() { + return new DestinationProfile( + new DestinationName("email-work"), + "rabbit-primary", + DestinationKind.WORK_QUEUE, + PhysicalDestination.rabbitQueue("notification.work", "email", "notification.email.q"), + new SchemaPolicy( + ContentType.JSON, + SchemaCompatibility.BACKWARD, + Set.of(new MessageType("email.requested"))), + DeliveryGuarantee.AT_LEAST_ONCE, + OrderingScope.NONE, + ExternalSideEffectGuarantee.IDEMPOTENCY_REQUIRED, + ProducerPolicy.defaults(), + ConsumerPolicy.defaults("notification"), + RetryPolicy.none(), + DeadLetterPolicy.to(new DestinationName("email-work-dlq")), + PayloadPolicy.defaults(), + CapabilityTier.M1, + false, + false, + false); + } +} diff --git a/messaging/messaging-reliability-api/src/main/java/dev/caskeleton/messaging/reliability/OutboxRepository.java b/messaging/messaging-reliability-api/src/main/java/dev/caskeleton/messaging/reliability/OutboxRepository.java index 39f00a7..6552a3b 100644 --- a/messaging/messaging-reliability-api/src/main/java/dev/caskeleton/messaging/reliability/OutboxRepository.java +++ b/messaging/messaging-reliability-api/src/main/java/dev/caskeleton/messaging/reliability/OutboxRepository.java @@ -58,14 +58,6 @@ public interface OutboxRepository { List claimBatch( String owner, int batchSize, Duration leaseDuration, Instant now, int maxAttempts); - /** - * Marks a record as confirmed by the broker. - * - * @param messageId the record identity - * @param now the current instant - */ - void markPublished(MessageId messageId, Instant now); - /** * Records a confirmed publication, only if this lease still owns the row. * @@ -73,17 +65,6 @@ public interface OutboxRepository { */ OutboxTransitionResult markPublished(OutboxLease lease, Instant now); - /** - * Marks a record whose publish outcome is unknown. - * - *

The record stays eligible for retry under the same identity. - * - * @param messageId the record identity - * @param failureCode the sanitized failure code - * @param now the current instant - */ - void markAmbiguous(MessageId messageId, String failureCode, Instant now); - /** Records an ambiguous outcome, only if this lease still owns the row. */ OutboxTransitionResult markAmbiguous(OutboxLease lease, String failureCode, Instant now); @@ -99,25 +80,9 @@ public interface OutboxRepository { */ OutboxTransitionResult markExhausted(OutboxLease lease, String reason, Instant now); - /** - * Marks a record the broker definitively rejected. - * - * @param messageId the record identity - * @param failureCode the sanitized failure code - * @param now the current instant - */ - void markFailed(MessageId messageId, String failureCode, Instant now); - /** Records a terminal failure, only if this lease still owns the row. */ OutboxTransitionResult markFailed(OutboxLease lease, String failureCode, Instant now); - /** - * Releases a lease without changing the record's outcome. - * - * @param messageId the record identity - */ - void releaseLease(MessageId messageId); - /** Gives a claim back, only if this lease still owns the row. */ OutboxTransitionResult releaseLease(OutboxLease lease); diff --git a/messaging/messaging-reliability-api/src/test/java/dev/caskeleton/messaging/reliability/OutboxRepositoryApiSafetyTest.java b/messaging/messaging-reliability-api/src/test/java/dev/caskeleton/messaging/reliability/OutboxRepositoryApiSafetyTest.java new file mode 100644 index 0000000..72c780e --- /dev/null +++ b/messaging/messaging-reliability-api/src/test/java/dev/caskeleton/messaging/reliability/OutboxRepositoryApiSafetyTest.java @@ -0,0 +1,24 @@ +package dev.caskeleton.messaging.reliability; + +import static org.assertj.core.api.Assertions.assertThat; + +import dev.caskeleton.messaging.api.MessageId; +import java.lang.reflect.Method; +import java.util.Set; +import org.junit.jupiter.api.Test; + +class OutboxRepositoryApiSafetyTest { + @Test + void outcomeTransitionsDoNotExposeUnfencedMessageIdOverloadsUnderTheSafeNames() { + Set fencedNames = + Set.of("markPublished", "markAmbiguous", "markFailed", "releaseLease"); + + assertThat(OutboxRepository.class.getMethods()) + .filteredOn(method -> fencedNames.contains(method.getName())) + .noneMatch(OutboxRepositoryApiSafetyTest::startsWithMessageId); + } + + private static boolean startsWithMessageId(Method method) { + return method.getParameterCount() > 0 && method.getParameterTypes()[0] == MessageId.class; + } +} diff --git a/messaging/messaging-schema-protobuf/build.gradle b/messaging/messaging-schema-protobuf/build.gradle index 054e094..3c431b4 100644 --- a/messaging/messaging-schema-protobuf/build.gradle +++ b/messaging/messaging-schema-protobuf/build.gradle @@ -8,5 +8,5 @@ dependencies { // api: ProtobufMessageContract is a public record over com.google.protobuf.Message and // Parser, and registering a contract is the first thing a consumer of this codec does. - api libs.protobuf.java.legacy + api libs.protobuf.java } diff --git a/messaging/messaging-schema-protobuf/gradle.lockfile b/messaging/messaging-schema-protobuf/gradle.lockfile index 15b6267..85388e0 100644 --- a/messaging/messaging-schema-protobuf/gradle.lockfile +++ b/messaging/messaging-schema-protobuf/gradle.lockfile @@ -23,8 +23,7 @@ com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor com.google.guava:guava:33.6.0-jre=checkstyle com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.29.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins com.puppycrawl.tools:checkstyle:13.5.0=checkstyle commons-beanutils:commons-beanutils:1.11.0=checkstyle diff --git a/messaging/messaging-spring-boot-starter-kafka/build.gradle b/messaging/messaging-spring-boot-starter-kafka/build.gradle new file mode 100644 index 0000000..9333a84 --- /dev/null +++ b/messaging/messaging-spring-boot-starter-kafka/build.gradle @@ -0,0 +1,13 @@ +plugins { + id 'ca.platform-module' + id 'ca.spring-config' +} + +dependencies { + // Capability artifact: selecting Kafka is a build-time decision. The core starter contains no + // Kafka client classes. + api project(':messaging:messaging-spring-boot-starter') + api project(':messaging:messaging-kafka') + + implementation 'org.springframework.boot:spring-boot-autoconfigure' +} diff --git a/messaging/messaging-spring-boot-starter-kafka/gradle.lockfile b/messaging/messaging-spring-boot-starter-kafka/gradle.lockfile new file mode 100644 index 0000000..6e4716f --- /dev/null +++ b/messaging/messaging-spring-boot-starter-kafka/gradle.lockfile @@ -0,0 +1,115 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +at.yawk.lz4:lz4-java:1.10.1=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-annotations:2.21=runtimeClasspath,testRuntimeClasspath +com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor +com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor +com.github.luben:zstd-jni:1.5.6-10=runtimeClasspath,testRuntimeClasspath +com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs +com.github.spotbugs:spotbugs:4.10.2=spotbugs +com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs +com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor +com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor +com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor +com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs +com.google.code.gson:gson:2.13.2=spotbugs +com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.41.0=spotbugs +com.google.errorprone:error_prone_annotations:2.47.0=checkstyle +com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor +com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor +com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor +com.google.guava:guava:33.6.0-jre=checkstyle +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor +com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor +com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins +com.puppycrawl.tools:checkstyle:13.5.0=checkstyle +commons-beanutils:commons-beanutils:1.11.0=checkstyle +commons-collections:commons-collections:3.2.2=checkstyle +commons-io:commons-io:2.21.0=spotbugs +commons-logging:commons-logging:1.3.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +info.picocli:picocli:4.7.7=checkstyle +io.cloudevents:cloudevents-api:4.0.1=runtimeClasspath,testRuntimeClasspath +io.cloudevents:cloudevents-core:4.0.1=runtimeClasspath,testRuntimeClasspath +io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor +io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor +io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-core:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.projectreactor:reactor-core:3.8.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor +jaxen:jaxen:2.0.6=spotbugs +net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath +net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs +org.antlr:antlr4-runtime:4.13.2=checkstyle +org.apache.bcel:bcel:6.12.0=spotbugs +org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs +org.apache.commons:commons-text:1.15.0=spotbugs +org.apache.commons:commons-text:1.3=checkstyle +org.apache.httpcomponents:httpclient:4.5.13=checkstyle +org.apache.httpcomponents:httpcore:4.4.16=checkstyle +org.apache.kafka:kafka-clients:4.1.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.logging.log4j:log4j-api:2.25.5=spotbugs +org.apache.logging.log4j:log4j-core:2.25.5=spotbugs +org.apache.maven.doxia:doxia-core:1.12.0=checkstyle +org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle +org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle +org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle +org.apache.xbean:xbean-reflect:3.7=checkstyle +org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath +org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath +org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle +org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle +org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle +org.codehaus.plexus:plexus-utils:3.3.0=checkstyle +org.dom4j:dom4j:2.2.0=spotbugs +org.hdrhistogram:HdrHistogram:2.2.2=runtimeClasspath,testRuntimeClasspath +org.javassist:javassist:3.28.0-GA=checkstyle +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath +org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath +org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit:junit-bom:6.1.0=spotbugs +org.latencyutils:LatencyUtils:2.0.3=runtimeClasspath,testRuntimeClasspath +org.mockito:mockito-core:5.20.0=mockitoAgent +org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath +org.ow2.asm:asm-analysis:9.10.1=spotbugs +org.ow2.asm:asm-commons:9.10.1=spotbugs +org.ow2.asm:asm-tree:9.10.1=spotbugs +org.ow2.asm:asm-util:9.10.1=spotbugs +org.ow2.asm:asm:9.10.1=spotbugs +org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor +org.reactivestreams:reactive-streams:1.0.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.reflections:reflections:0.10.2=checkstyle +org.slf4j:slf4j-api:2.0.18=runtimeClasspath,spotbugs,spotbugsSlf4j,testRuntimeClasspath +org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j +org.slf4j:slf4j-simple:2.0.18=checkstyle +org.springframework.boot:spring-boot-actuator:4.0.8=runtimeClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-autoconfigure:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-configuration-processor:4.0.8=annotationProcessor +org.springframework.boot:spring-boot:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.kafka:spring-kafka:4.0.7=runtimeClasspath,testRuntimeClasspath +org.springframework:spring-aop:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-context:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-expression:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-jdbc:7.0.9=runtimeClasspath,testRuntimeClasspath +org.springframework:spring-messaging:7.0.9=runtimeClasspath,testRuntimeClasspath +org.springframework:spring-tx:7.0.9=runtimeClasspath,testRuntimeClasspath +org.xerial.snappy:snappy-java:1.1.10.7=runtimeClasspath,testRuntimeClasspath +org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs +tools.jackson.core:jackson-core:3.1.5=runtimeClasspath,testRuntimeClasspath +tools.jackson.core:jackson-databind:3.1.5=runtimeClasspath,testRuntimeClasspath +tools.jackson:jackson-bom:3.1.5=runtimeClasspath,testRuntimeClasspath +empty= diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/KafkaMessagingAutoConfiguration.java b/messaging/messaging-spring-boot-starter-kafka/src/main/java/dev/caskeleton/messaging/autoconfigure/KafkaMessagingAutoConfiguration.java similarity index 86% rename from messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/KafkaMessagingAutoConfiguration.java rename to messaging/messaging-spring-boot-starter-kafka/src/main/java/dev/caskeleton/messaging/autoconfigure/KafkaMessagingAutoConfiguration.java index 5525380..cc2b247 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/KafkaMessagingAutoConfiguration.java +++ b/messaging/messaging-spring-boot-starter-kafka/src/main/java/dev/caskeleton/messaging/autoconfigure/KafkaMessagingAutoConfiguration.java @@ -59,7 +59,7 @@ public class KafkaMessagingAutoConfiguration { return new StartupProfileValidation<>( () -> java.util.stream.Stream.concat( - compiled.kafkaBrokers().stream(), profiles.orderedStream()) + configuredKafkaProfiles(compiled).stream(), profiles.orderedStream()) .toList(), validator::validate); } @@ -167,4 +167,31 @@ public class KafkaMessagingAutoConfiguration { // the first rotation look like it had already happened. return new dev.caskeleton.messaging.kafka.KafkaMessagingTransport("kafka", 1L, producer); } + + private static java.util.List + configuredKafkaProfiles(CompiledMessagingConfiguration compiled) { + return compiled.brokers().entrySet().stream() + .filter( + entry -> + entry.getValue().type() != null + && entry.getValue().type().equalsIgnoreCase(BrokerSettings.KAFKA)) + .map( + entry -> { + BrokerSettings broker = entry.getValue(); + return new dev.caskeleton.messaging.kafka.KafkaBrokerProfile( + entry.getKey(), + broker.stable(), + broker.production(), + broker.bootstrapServers(), + broker.enableIdempotence(), + broker.acks(), + broker.maxInFlightRequestsPerConnection(), + broker.deliveryTimeout(), + broker.enableAutoCommit(), + broker.consumerGroup(), + broker.tlsEnabled(), + broker.authenticationEnabled()); + }) + .toList(); + } } diff --git a/messaging/messaging-spring-boot-starter-rabbit/build.gradle b/messaging/messaging-spring-boot-starter-rabbit/build.gradle new file mode 100644 index 0000000..3635e1c --- /dev/null +++ b/messaging/messaging-spring-boot-starter-rabbit/build.gradle @@ -0,0 +1,12 @@ +plugins { + id 'ca.platform-module' + id 'ca.spring-config' +} + +dependencies { + // Capability artifact: Rabbit types/client exist only when this artifact is deliberately added. + api project(':messaging:messaging-spring-boot-starter') + api project(':messaging:messaging-rabbit') + + implementation 'org.springframework.boot:spring-boot-autoconfigure' +} diff --git a/messaging/messaging-spring-boot-starter-rabbit/gradle.lockfile b/messaging/messaging-spring-boot-starter-rabbit/gradle.lockfile new file mode 100644 index 0000000..1d3075d --- /dev/null +++ b/messaging/messaging-spring-boot-starter-rabbit/gradle.lockfile @@ -0,0 +1,124 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +com.fasterxml.jackson.core:jackson-annotations:2.21=runtimeClasspath,testRuntimeClasspath +com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor +com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor +com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs +com.github.spotbugs:spotbugs:4.10.2=spotbugs +com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs +com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor +com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor +com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor +com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs +com.google.code.gson:gson:2.13.2=spotbugs +com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.41.0=spotbugs +com.google.errorprone:error_prone_annotations:2.47.0=checkstyle +com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor +com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor +com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor +com.google.guava:guava:33.6.0-jre=checkstyle +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor +com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor +com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins +com.puppycrawl.tools:checkstyle:13.5.0=checkstyle +com.rabbitmq:amqp-client:5.27.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-beanutils:commons-beanutils:1.11.0=checkstyle +commons-collections:commons-collections:3.2.2=checkstyle +commons-io:commons-io:2.21.0=spotbugs +commons-logging:commons-logging:1.3.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +info.picocli:picocli:4.7.7=checkstyle +io.cloudevents:cloudevents-api:4.0.1=runtimeClasspath,testRuntimeClasspath +io.cloudevents:cloudevents-core:4.0.1=runtimeClasspath,testRuntimeClasspath +io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor +io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor +io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-core:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-buffer:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-base:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-compression:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-marshalling:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-protobuf:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-common:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-handler:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-resolver:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-transport-native-unix-common:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-transport:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.projectreactor:reactor-core:3.8.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor +jaxen:jaxen:2.0.6=spotbugs +net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath +net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs +org.antlr:antlr4-runtime:4.13.2=checkstyle +org.apache.bcel:bcel:6.12.0=spotbugs +org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs +org.apache.commons:commons-text:1.15.0=spotbugs +org.apache.commons:commons-text:1.3=checkstyle +org.apache.httpcomponents:httpclient:4.5.13=checkstyle +org.apache.httpcomponents:httpcore:4.4.16=checkstyle +org.apache.logging.log4j:log4j-api:2.25.5=spotbugs +org.apache.logging.log4j:log4j-core:2.25.5=spotbugs +org.apache.maven.doxia:doxia-core:1.12.0=checkstyle +org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle +org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle +org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle +org.apache.xbean:xbean-reflect:3.7=checkstyle +org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath +org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath +org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle +org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle +org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle +org.codehaus.plexus:plexus-utils:3.3.0=checkstyle +org.dom4j:dom4j:2.2.0=spotbugs +org.hdrhistogram:HdrHistogram:2.2.2=runtimeClasspath,testRuntimeClasspath +org.javassist:javassist:3.28.0-GA=checkstyle +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath +org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath +org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit:junit-bom:6.1.0=spotbugs +org.latencyutils:LatencyUtils:2.0.3=runtimeClasspath,testRuntimeClasspath +org.mockito:mockito-core:5.20.0=mockitoAgent +org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath +org.ow2.asm:asm-analysis:9.10.1=spotbugs +org.ow2.asm:asm-commons:9.10.1=spotbugs +org.ow2.asm:asm-tree:9.10.1=spotbugs +org.ow2.asm:asm-util:9.10.1=spotbugs +org.ow2.asm:asm:9.10.1=spotbugs +org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor +org.reactivestreams:reactive-streams:1.0.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.reflections:reflections:0.10.2=checkstyle +org.slf4j:slf4j-api:2.0.18=compileClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath +org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j +org.slf4j:slf4j-simple:2.0.18=checkstyle +org.springframework.amqp:spring-amqp:4.0.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.amqp:spring-rabbit:4.0.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-actuator:4.0.8=runtimeClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-autoconfigure:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-configuration-processor:4.0.8=annotationProcessor +org.springframework.boot:spring-boot:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-aop:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-context:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-expression:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-jdbc:7.0.9=runtimeClasspath,testRuntimeClasspath +org.springframework:spring-messaging:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-tx:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs +tools.jackson.core:jackson-core:3.1.5=runtimeClasspath,testRuntimeClasspath +tools.jackson.core:jackson-databind:3.1.5=runtimeClasspath,testRuntimeClasspath +tools.jackson:jackson-bom:3.1.5=runtimeClasspath,testRuntimeClasspath +empty= diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/RabbitMessagingAutoConfiguration.java b/messaging/messaging-spring-boot-starter-rabbit/src/main/java/dev/caskeleton/messaging/autoconfigure/RabbitMessagingAutoConfiguration.java similarity index 75% rename from messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/RabbitMessagingAutoConfiguration.java rename to messaging/messaging-spring-boot-starter-rabbit/src/main/java/dev/caskeleton/messaging/autoconfigure/RabbitMessagingAutoConfiguration.java index 66b14dd..f64cd42 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/RabbitMessagingAutoConfiguration.java +++ b/messaging/messaging-spring-boot-starter-rabbit/src/main/java/dev/caskeleton/messaging/autoconfigure/RabbitMessagingAutoConfiguration.java @@ -55,7 +55,7 @@ public class RabbitMessagingAutoConfiguration { return new StartupProfileValidation<>( () -> java.util.stream.Stream.concat( - compiled.rabbitBrokers().stream(), profiles.orderedStream()) + configuredRabbitProfiles(compiled).stream(), profiles.orderedStream()) .toList(), validator::validate); } @@ -95,4 +95,32 @@ public class RabbitMessagingAutoConfiguration { CredentialRuntimeRegistry credentials, BrokerTlsPolicy tlsPolicy) { return new RabbitSecurityConfigurer(credentials, tlsPolicy); } + + private static java.util.List + configuredRabbitProfiles(CompiledMessagingConfiguration compiled) { + return compiled.brokers().entrySet().stream() + .filter( + entry -> + entry.getValue().type() != null + && entry.getValue().type().equalsIgnoreCase(BrokerSettings.RABBITMQ)) + .map( + entry -> { + BrokerSettings broker = entry.getValue(); + return new dev.caskeleton.messaging.rabbit.RabbitBrokerProfile( + entry.getKey(), + broker.stable(), + broker.production(), + broker.addresses(), + broker.publisherConfirms(), + broker.publisherReturns(), + broker.mandatory(), + broker.confirmTimeout(), + broker.autoAck(), + broker.prefetch(), + broker.quorumQueues(), + broker.tlsEnabled(), + broker.authenticationEnabled()); + }) + .toList(); + } } diff --git a/messaging/messaging-spring-boot-starter/README.md b/messaging/messaging-spring-boot-starter/README.md index c99440e..9580cea 100644 --- a/messaging/messaging-spring-boot-starter/README.md +++ b/messaging/messaging-spring-boot-starter/README.md @@ -1,26 +1,47 @@ # messaging-spring-boot-starter -## 아티팩트 분리 (예정) +## 아티팩트 분리 -이 starter는 현재 하나의 아티팩트로 Kafka·Rabbit·JDBC reliability·admin 자동설정을 모두 등록한다. -MSG-007이 요구하는 최종 형태는 capability별 분리다: +기본 `messaging-spring-boot-starter`는 이제 **broker-neutral core**다. Kafka/Rabbit client를 +production runtime에 직접 넣지 않으며, 브로커 채택은 capability artifact를 composition에 추가하는 +build-time 결정이다. ```text -messaging-spring-boot-autoconfigure-core -messaging-spring-boot-starter-core -messaging-spring-boot-starter-kafka -messaging-spring-boot-starter-rabbit -messaging-spring-boot-starter-reliability-jdbc-postgresql -messaging-spring-boot-starter-admin +messaging-spring-boot-starter +├─ messaging-spring-boot-starter-kafka # Kafka client/transport capability +└─ messaging-spring-boot-starter-rabbit # Rabbit profile/validator capability ``` -지금 반영된 것과 남은 것을 분명히 적는다. +- 기본 app-bootstrap은 core starter만 가진다. 따라서 messaging off/default runtime에는 + `kafka-clients`, `spring-kafka`, `spring-rabbit`, `amqp-client`가 없다. +- Kafka를 채택하는 composition은 `:messaging:messaging-spring-boot-starter-kafka`를 추가한다. +- Rabbit capability도 별도 artifact지만, 아래 설명처럼 아직 production transport가 없어 + `app.messaging.broker=rabbit` 선택은 startup에서 거부된다. +- reliability/admin의 추가 artifact 분리는 별도 구조 개선 여지로 남지만, broker SDK 동시 탑재 문제와 + transport 선택 문제는 core/broker capability 분리로 해소했다. +- legacy R0 outbound bridge도 같은 원칙을 따른다. broker-neutral + `:adapter:outbound:messaging`과 Kafka 전용 `:adapter:outbound:messaging-kafka`가 분리돼 있다. -- **반영**: 내부 leaf 9개를 `api` → `implementation`으로 낮췄다. 어댑터를 쓰지 않는 소비자의 컴파일 - classpath에 두 브로커 SDK가 더 이상 올라가지 않는다. -- **반영**: 브로커 security configurer는 `CredentialRuntimeRegistry` 빈이 있을 때만 만들어지고, - production 프로파일에 credential 소스가 없으면 `MessagingCredentialRequirementValidator`가 - 내부 타입 이름이 아니라 조치 가능한 한 개의 오류로 실패시킨다. -- **남음**: 아티팩트 자체의 분리. 레지스트리(43→44에서 다시 49)와 `AutoConfiguration.imports` 분할을 - 함께 바꾸는 변경이라 별도 커밋으로 다룬다. 그 전까지 런타임 의존성(`runtimeClasspath`)에는 여전히 - 두 브로커가 함께 들어온다. +## 현재 broker/runtime 지원 범위 + +### Kafka + +Kafka publish runtime은 **Kafka capability artifact를 추가한 composition에서만** 조립된다. +`KafkaMessagingTransport`는 publish runtime으로 설치되지만, `KafkaConsumerRegistrar`는 capability +starter나 app-bootstrap에서 자동 생성하지 않는다. 따라서 현재 자동조립된 transport에 consume +registration을 요청하면 `KAFKA_CONSUMER_NOT_CONFIGURED`로 실패한다. + +consume을 채택하려면 애플리케이션 composition이 별도로 `KafkaConsumerRegistrar`와 handler sink를 +조립해야 한다. leaf 안의 consumer/rebalance/settlement 테스트가 초록이라는 사실은 capability +starter가 consumer runtime까지 자동 제공한다는 뜻이 아니다. + +### RabbitMQ + +RabbitMQ는 별도 capability artifact에 격리되어 있지만 **아직 선택할 수 없는 transport**다. +`app.messaging.broker=rabbit`을 설정하면 `MessagingProviderSelection`이 startup에서 거부한다. +이 leaf에는 validator, failure classifier, topology/security 부품과 테스트는 있지만 production +`RabbitChannelPublisher` 구현이 없어 `MessagingTransport`를 완성할 수 없다. + +현재 selectable broker는 Kafka뿐이다. Rabbit이 selectable로 승격되는 조건은 production +channel publisher/settlement bridge를 구현하고 starter composition 및 broker integration 증거를 +함께 추가하는 것이다. diff --git a/messaging/messaging-spring-boot-starter/build.gradle b/messaging/messaging-spring-boot-starter/build.gradle index 448d06a..14167fa 100644 --- a/messaging/messaging-spring-boot-starter/build.gradle +++ b/messaging/messaging-spring-boot-starter/build.gradle @@ -1,4 +1,5 @@ plugins { + id 'ca.auxiliary-source-set' id 'ca.platform-module' id 'ca.spring-config' } @@ -14,6 +15,12 @@ plugins { // is `implementation`. Splitting the starter into per-capability artifacts (core / kafka / rabbit / // reliability / admin) is the structural fix the review asks for and is a registry change of its // own; this is the part that stops an adopter's compile classpath from containing two broker SDKs. +auxiliarySourceSets { + sourceSet('integrationTest') { + compilesAgainst 'main' + } +} + dependencies { // Types an adopter writes against: envelopes, destinations, publish results, profiles, ports. api project(':messaging:messaging-core-api') @@ -31,8 +38,6 @@ dependencies { // which is why MessagingCoreAutoConfiguration consumed a MessagePublisher that nothing in // reach could produce (MSG-INT-003). implementation project(':messaging:messaging-runtime-core') - implementation project(':messaging:messaging-kafka') - implementation project(':messaging:messaging-rabbit') implementation project(':messaging:messaging-outbox-jdbc-postgresql') implementation project(':messaging:messaging-inbox-jdbc-postgresql') implementation project(':messaging:messaging-claim-check') @@ -50,6 +55,10 @@ dependencies { testImplementation 'io.projectreactor:reactor-test' testImplementation 'org.springframework.boot:spring-boot-test' testImplementation 'org.springframework:spring-test' + // Provider auto-configurations live in capability artifacts. Tests that exercise provider + // selection add them only to the test graph; the production starter remains broker-neutral. + testImplementation project(':messaging:messaging-spring-boot-starter-kafka') + testImplementation project(':messaging:messaging-spring-boot-starter-rabbit') // Test-only, and specifically so the configuration reference can be executed rather than read: // MessagingConfigurationBindingTest loads the YAML blocks out of the shipped document and boots // a context on them. Spring Boot 4 treats snakeyaml as optional, so a document-driven test has @@ -59,6 +68,15 @@ dependencies { // app-bootstrap membership in the same change that proves a real broker round trip, // so the proof has to run somewhere — and the starter is where the whole platform // assembles. - testImplementation 'org.testcontainers:testcontainers-junit-jupiter' - testImplementation 'org.testcontainers:testcontainers-kafka' + integrationTestImplementation project(':messaging:messaging-spring-boot-starter-kafka') + integrationTestImplementation 'org.testcontainers:testcontainers-junit-jupiter' + integrationTestImplementation 'org.testcontainers:testcontainers-kafka' +} + +strictTestLanes { + lane('integrationTest') { + integration() + sourceSet = 'integrationTest' + description = 'Runs the assembled messaging starter round trip against real Kafka.' + } } diff --git a/messaging/messaging-spring-boot-starter/gradle.lockfile b/messaging/messaging-spring-boot-starter/gradle.lockfile index c873ea4..af7c26e 100644 --- a/messaging/messaging-spring-boot-starter/gradle.lockfile +++ b/messaging/messaging-spring-boot-starter/gradle.lockfile @@ -1,79 +1,79 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -at.yawk.lz4:lz4-java:1.10.1=runtimeClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-annotations:2.21=runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.docker-java:docker-java-api:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport-zerodep:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.docker-java:docker-java-transport:3.7.1=testCompileClasspath,testRuntimeClasspath -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.luben:zstd-jni:1.5.6-10=runtimeClasspath,testRuntimeClasspath +at.yawk.lz4:lz4-java:1.10.1=integrationTestRuntimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-annotations:2.21=integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.github.docker-java:docker-java-api:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport-zerodep:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.docker-java:docker-java-transport:3.7.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath +com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.github.luben:zstd-jni:1.5.6-10=integrationTestRuntimeClasspath,testRuntimeClasspath com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs com.github.spotbugs:spotbugs:4.10.2=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor +com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.auto:auto-common:1.2.2=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.errorprone:error_prone_annotations:2.41.0=spotbugs com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:guava:33.5.0-jre=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,integrationTestAnnotationProcessor,testAnnotationProcessor +com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -com.rabbitmq:amqp-client:5.27.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.rabbitmq:amqp-client:5.27.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-codec:commons-codec:1.19.0=testCompileClasspath,testRuntimeClasspath +commons-codec:commons-codec:1.19.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.20.0=testCompileClasspath,testRuntimeClasspath +commons-io:commons-io:2.20.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-logging:commons-logging:1.3.6=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle -io.cloudevents:cloudevents-api:4.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.cloudevents:cloudevents-core:4.0.1=runtimeClasspath,testRuntimeClasspath -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-core:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-buffer:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-base:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-compression:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-marshalling:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec-protobuf:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-codec:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-common:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-handler:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-resolver:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-transport-native-unix-common:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.netty:netty-transport:4.2.17.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.projectreactor:reactor-core:3.8.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.projectreactor:reactor-test:3.8.7=testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor +io.cloudevents:cloudevents-api:4.0.1=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.cloudevents:cloudevents-core:4.0.1=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +io.micrometer:micrometer-commons:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-core:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-observation:1.16.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-buffer:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-base:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-compression:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-marshalling:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec-protobuf:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-codec:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-common:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-handler:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-resolver:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-transport-native-unix-common:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.netty:netty-transport:4.2.17.Final=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +io.projectreactor:reactor-core:3.8.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.projectreactor:reactor-test:3.8.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +javax.inject:javax.inject:1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.18.1=testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.17.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.java.dev.jna:jna:5.18.1=integrationTestCompileClasspath,integrationTestRuntimeClasspath net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs org.antlr:antlr4-runtime:4.13.2=checkstyle org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-compress:1.28.0=testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-compress:1.28.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.apache.commons:commons-lang3:3.20.0=checkstyle,integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs org.apache.commons:commons-text:1.15.0=spotbugs org.apache.commons:commons-text:1.3=checkstyle org.apache.httpcomponents:httpclient:4.5.13=checkstyle org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.kafka:kafka-clients:4.1.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.kafka:kafka-clients:4.1.2=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.logging.log4j:log4j-api:2.25.5=spotbugs org.apache.logging.log4j:log4j-core:2.25.5=spotbugs org.apache.maven.doxia:doxia-core:1.12.0=checkstyle @@ -81,65 +81,65 @@ org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath +org.apiguardian:apiguardian-api:1.1.2=integrationTestCompileClasspath,testCompileClasspath +org.assertj:assertj-core:3.27.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle org.codehaus.plexus:plexus-utils:3.3.0=checkstyle org.dom4j:dom4j:2.2.0=spotbugs -org.hdrhistogram:HdrHistogram:2.2.2=runtimeClasspath,testRuntimeClasspath +org.hdrhistogram:HdrHistogram:2.2.2=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath org.javassist:javassist:3.28.0-GA=checkstyle -org.jetbrains:annotations:17.0.0=testCompileClasspath,testRuntimeClasspath -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath +org.jetbrains:annotations:17.0.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,integrationTestAnnotationProcessor,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-launcher:6.0.3=integrationTestRuntimeClasspath,testRuntimeClasspath +org.junit:junit-bom:6.0.3=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.junit:junit-bom:6.1.0=spotbugs -org.latencyutils:LatencyUtils:2.0.3=runtimeClasspath,testRuntimeClasspath +org.latencyutils:LatencyUtils:2.0.3=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.3.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.ow2.asm:asm-analysis:9.10.1=spotbugs org.ow2.asm:asm-commons:9.10.1=spotbugs org.ow2.asm:asm-tree:9.10.1=spotbugs org.ow2.asm:asm-util:9.10.1=spotbugs org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reactivestreams:reactive-streams:1.0.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.pcollections:pcollections:4.0.1=annotationProcessor,integrationTestAnnotationProcessor,testAnnotationProcessor +org.reactivestreams:reactive-streams:1.0.4=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.reflections:reflections:0.10.2=checkstyle -org.rnorth.duct-tape:duct-tape:1.0.8=testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:2.0.18=compileClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath +org.rnorth.duct-tape:duct-tape:1.0.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.slf4j:slf4j-api:2.0.18=integrationTestCompileClasspath,integrationTestRuntimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework.amqp:spring-amqp:4.0.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework.amqp:spring-rabbit:4.0.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework.boot:spring-boot-actuator:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework.boot:spring-boot-autoconfigure:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.amqp:spring-amqp:4.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.amqp:spring-rabbit:4.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-actuator:4.0.8=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-autoconfigure:4.0.8=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework.boot:spring-boot-configuration-processor:4.0.8=annotationProcessor -org.springframework.boot:spring-boot-test:4.0.8=testCompileClasspath,testRuntimeClasspath -org.springframework.boot:spring-boot:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework.kafka:spring-kafka:4.0.7=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-aop:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-context:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-expression:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-jdbc:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-messaging:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-test:7.0.9=testCompileClasspath,testRuntimeClasspath -org.springframework:spring-tx:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-junit-jupiter:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers-kafka:2.0.5=testCompileClasspath,testRuntimeClasspath -org.testcontainers:testcontainers:2.0.5=testCompileClasspath,testRuntimeClasspath -org.xerial.snappy:snappy-java:1.1.10.7=runtimeClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot-test:4.0.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.boot:spring-boot:4.0.8=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework.kafka:spring-kafka:4.0.7=integrationTestRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-aop:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-beans:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-context:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-core:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-expression:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-jdbc:7.0.9=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +org.springframework:spring-messaging:7.0.9=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-test:7.0.9=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.springframework:spring-tx:7.0.9=integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.testcontainers:testcontainers-junit-jupiter:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers-kafka:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.testcontainers:testcontainers:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath +org.xerial.snappy:snappy-java:1.1.10.7=integrationTestRuntimeClasspath,testRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -org.yaml:snakeyaml:2.5=testCompileClasspath,testRuntimeClasspath -tools.jackson.core:jackson-core:3.1.5=runtimeClasspath,testRuntimeClasspath -tools.jackson.core:jackson-databind:3.1.5=runtimeClasspath,testRuntimeClasspath -tools.jackson:jackson-bom:3.1.5=runtimeClasspath,testRuntimeClasspath +org.yaml:snakeyaml:2.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +tools.jackson.core:jackson-core:3.1.5=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +tools.jackson.core:jackson-databind:3.1.5=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +tools.jackson:jackson-bom:3.1.5=integrationTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath empty= diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingLiveRoundTripQualificationTest.java b/messaging/messaging-spring-boot-starter/src/integrationTest/java/dev/caskeleton/messaging/autoconfigure/MessagingLiveRoundTripQualificationTest.java similarity index 98% rename from messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingLiveRoundTripQualificationTest.java rename to messaging/messaging-spring-boot-starter/src/integrationTest/java/dev/caskeleton/messaging/autoconfigure/MessagingLiveRoundTripQualificationTest.java index ceaa89c..8fdc0a2 100644 --- a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingLiveRoundTripQualificationTest.java +++ b/messaging/messaging-spring-boot-starter/src/integrationTest/java/dev/caskeleton/messaging/autoconfigure/MessagingLiveRoundTripQualificationTest.java @@ -180,7 +180,9 @@ class MessagingLiveRoundTripQualificationTest { ContentType.JSON, dev.caskeleton.messaging.schema.SchemaCompatibility.BACKWARD_TRANSITIVE, java.util.Set.of(new MessageType("order.created"))), - dev.caskeleton.messaging.api.delivery.DeliveryGuarantee.AT_LEAST_ONCE, + deadLetter == null + ? dev.caskeleton.messaging.api.delivery.DeliveryGuarantee.AT_MOST_ONCE + : dev.caskeleton.messaging.api.delivery.DeliveryGuarantee.AT_LEAST_ONCE, dev.caskeleton.messaging.api.delivery.OrderingScope.NONE, dev.caskeleton.messaging.api.delivery.ExternalSideEffectGuarantee.IDEMPOTENCY_REQUIRED, dev.caskeleton.messaging.policy.ProducerPolicy.defaults(), diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/CompiledMessagingConfiguration.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/CompiledMessagingConfiguration.java index 661fcd6..7b65e6a 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/CompiledMessagingConfiguration.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/CompiledMessagingConfiguration.java @@ -1,53 +1,43 @@ package dev.caskeleton.messaging.autoconfigure; -import dev.caskeleton.messaging.kafka.KafkaBrokerProfile; import dev.caskeleton.messaging.policy.DestinationProfile; -import dev.caskeleton.messaging.rabbit.RabbitBrokerProfile; import dev.caskeleton.messaging.security.BrokerSecurityProfile; import java.util.List; +import java.util.Map; import java.util.Objects; /** - * What the documented configuration compiles to. + * What the documented broker-neutral configuration compiles to. * - *

One object rather than four beans, because the four are only meaningful together: a - * destination names a broker, a security entry secures one, and a compile that produced three of - * the four would leave the fourth silently empty. Holding them as one result means the startup - * validations either all see this deployment's configuration or the compile failed. + *

The core starter owns destination/security policy and the raw broker settings an adopter + * wrote. It deliberately does not construct Kafka or Rabbit profile types: doing that here would + * make the supposedly core artifact depend on both broker adapters. A broker capability compiles + * its own profile from {@link #brokers()} only when that capability artifact is present. * * @param destinations the destination profiles built from {@code app.messaging.destinations} - * @param kafkaBrokers the Kafka profiles built from {@code app.messaging.brokers} - * @param rabbitBrokers the RabbitMQ profiles built from {@code app.messaging.brokers} + * @param brokers the validated broker settings keyed by logical broker name * @param security the broker security profiles built from {@code app.messaging.security} */ public record CompiledMessagingConfiguration( List destinations, - List kafkaBrokers, - List rabbitBrokers, + Map brokers, List security) { public CompiledMessagingConfiguration { Objects.requireNonNull(destinations, "destinations must not be null"); - Objects.requireNonNull(kafkaBrokers, "kafkaBrokers must not be null"); - Objects.requireNonNull(rabbitBrokers, "rabbitBrokers must not be null"); + Objects.requireNonNull(brokers, "brokers must not be null"); Objects.requireNonNull(security, "security must not be null"); destinations = List.copyOf(destinations); - kafkaBrokers = List.copyOf(kafkaBrokers); - rabbitBrokers = List.copyOf(rabbitBrokers); + brokers = Map.copyOf(brokers); security = List.copyOf(security); } /** * Returns the result of compiling a deployment that configured nothing. * - *

Empty is a legitimate state, not a failure: an application may still register its profiles - * as beans, which is how this platform worked before anything bound. What is not legitimate is a - * deployment that configured destinations and got this — which is why the compiler builds it only - * when the sections really are absent. - * * @return the empty compilation */ public static CompiledMessagingConfiguration empty() { - return new CompiledMessagingConfiguration(List.of(), List.of(), List.of(), List.of()); + return new CompiledMessagingConfiguration(List.of(), Map.of(), List.of()); } } diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/DefaultBatchMessagePublisher.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/DefaultBatchMessagePublisher.java index f6f6548..c45124d 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/DefaultBatchMessagePublisher.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/DefaultBatchMessagePublisher.java @@ -34,10 +34,11 @@ import java.util.function.Supplier; * already in flight when the first rejection arrives cannot be recalled, so they are still awaited * and reported; pretending otherwise would leave the caller unsure whether they landed. */ -public final class DefaultBatchMessagePublisher implements BatchMessagePublisher { +public final class DefaultBatchMessagePublisher implements BatchMessagePublisher, AutoCloseable { private final MessagePublisher publisher; private final Supplier clock; + private final java.util.concurrent.ScheduledExecutorService deadlines; /** * Creates a batch publisher over the single-message publisher. @@ -46,8 +47,24 @@ public final class DefaultBatchMessagePublisher implements BatchMessagePublisher * @param clock supplies the current instant */ public DefaultBatchMessagePublisher(MessagePublisher publisher, Supplier clock) { + this( + publisher, + clock, + java.util.concurrent.Executors.newSingleThreadScheduledExecutor( + runnable -> { + Thread thread = new Thread(runnable, "messaging-batch-deadline"); + thread.setDaemon(true); + return thread; + })); + } + + DefaultBatchMessagePublisher( + MessagePublisher publisher, + Supplier clock, + java.util.concurrent.ScheduledExecutorService deadlines) { this.publisher = Objects.requireNonNull(publisher, "publisher must not be null"); this.clock = Objects.requireNonNull(clock, "clock must not be null"); + this.deadlines = Objects.requireNonNull(deadlines, "deadlines must not be null"); } @Override @@ -111,7 +128,7 @@ public final class DefaultBatchMessagePublisher implements BatchMessagePublisher // Same for the scheduled future: cancelling it early would only save a no-op, and the task // checks `isDone` before completing anything. java.util.concurrent.ScheduledFuture ignoredDeadline = - DEADLINES.schedule( + deadlines.schedule( () -> { if (!completed.isDone()) { completed.complete( @@ -126,19 +143,10 @@ public final class DefaultBatchMessagePublisher implements BatchMessagePublisher return completed; } - /** - * One scheduler for batch deadlines. - * - *

A daemon thread so a pending deadline never keeps the JVM alive, and one shared instance - * because a scheduler per batch is a thread per batch. - */ - private static final java.util.concurrent.ScheduledExecutorService DEADLINES = - java.util.concurrent.Executors.newSingleThreadScheduledExecutor( - runnable -> { - Thread thread = new Thread(runnable, "messaging-batch-deadline"); - thread.setDaemon(true); - return thread; - }); + @Override + public void close() { + deadlines.shutdownNow(); + } private boolean anyRejected(List> pending) { return pending.stream() diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingAdminAutoConfiguration.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingAdminAutoConfiguration.java index 14bf022..5238ba6 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingAdminAutoConfiguration.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingAdminAutoConfiguration.java @@ -24,7 +24,10 @@ import org.springframework.context.annotation.Configuration; * or delete registers one itself, with an admin credential this runtime does not hold. */ @Configuration(proxyBeanMethods = false) -@ConditionalOnProperty(prefix = "app.messaging.admin", name = "enabled", havingValue = "true") +@ConditionalOnProperty( + prefix = MessagingSettings.PREFIX + ".admin", + name = "enabled", + havingValue = "true") public class MessagingAdminAutoConfiguration { /** diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationCompiler.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationCompiler.java index ca76445..dca2d39 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationCompiler.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationCompiler.java @@ -4,7 +4,6 @@ import dev.caskeleton.messaging.api.ContentType; import dev.caskeleton.messaging.api.MessageType; import dev.caskeleton.messaging.api.destination.DestinationName; import dev.caskeleton.messaging.api.error.MessagingConfigurationException; -import dev.caskeleton.messaging.kafka.KafkaBrokerProfile; import dev.caskeleton.messaging.policy.ConsumerPolicy; import dev.caskeleton.messaging.policy.DeadLetterPolicy; import dev.caskeleton.messaging.policy.DestinationProfile; @@ -13,7 +12,6 @@ import dev.caskeleton.messaging.policy.PhysicalDestination; import dev.caskeleton.messaging.policy.ProducerPolicy; import dev.caskeleton.messaging.policy.RetryPolicy; import dev.caskeleton.messaging.policy.SchemaPolicy; -import dev.caskeleton.messaging.rabbit.RabbitBrokerProfile; import dev.caskeleton.messaging.security.BrokerCredentialProfile; import dev.caskeleton.messaging.security.BrokerSecurityProfile; import dev.caskeleton.messaging.security.DestinationAccessPolicy; @@ -68,20 +66,7 @@ public final class MessagingConfigurationCompiler { */ public CompiledMessagingConfiguration compile() { Map brokers = settings.getBrokers(); - List kafka = new ArrayList<>(); - List rabbit = new ArrayList<>(); - brokers.forEach( - (name, broker) -> { - switch (familyOf(name, broker)) { - case BrokerSettings.KAFKA -> kafka.add(toKafkaProfile(name, broker)); - case BrokerSettings.RABBITMQ -> rabbit.add(toRabbitProfile(name, broker)); - default -> - throw configurationError( - key("brokers", name, "type"), - "'%s' is not a broker family this platform binds; use '%s' or '%s'" - .formatted(broker.type(), BrokerSettings.KAFKA, BrokerSettings.RABBITMQ)); - } - }); + brokers.forEach(MessagingConfigurationCompiler::validateBrokerSettings); List destinations = new ArrayList<>(); settings @@ -93,7 +78,7 @@ public final class MessagingConfigurationCompiler { .getSecurity() .forEach((name, entry) -> security.add(toSecurityProfile(name, entry, brokers))); - return new CompiledMessagingConfiguration(destinations, kafka, rabbit, security); + return new CompiledMessagingConfiguration(destinations, brokers, security); } private static String familyOf(String name, BrokerSettings broker) { @@ -106,49 +91,30 @@ public final class MessagingConfigurationCompiler { return broker.type().toLowerCase(Locale.ROOT); } - private static KafkaBrokerProfile toKafkaProfile(String name, BrokerSettings broker) { - if (broker.bootstrapServers().isEmpty()) { - throw configurationError( - key("brokers", name, "bootstrap-servers"), - "a Kafka broker needs at least one address; a client with none defaults to " - + "localhost:9092 and fails at the first publish rather than at startup"); + private static void validateBrokerSettings(String name, BrokerSettings broker) { + switch (familyOf(name, broker)) { + case BrokerSettings.KAFKA -> { + if (broker.bootstrapServers().isEmpty()) { + throw configurationError( + key("brokers", name, "bootstrap-servers"), + "a Kafka broker needs at least one address; a client with none defaults to " + + "localhost:9092 and fails at the first publish rather than at startup"); + } + } + case BrokerSettings.RABBITMQ -> { + if (broker.addresses().isEmpty()) { + throw configurationError( + key("brokers", name, "addresses"), + "a RabbitMQ broker needs at least one address; a client with none defaults to " + + "localhost and connects as guest"); + } + } + default -> + throw configurationError( + key("brokers", name, "type"), + "'%s' is not a broker family this platform binds; use '%s' or '%s'" + .formatted(broker.type(), BrokerSettings.KAFKA, BrokerSettings.RABBITMQ)); } - return new KafkaBrokerProfile( - name, - broker.stable(), - broker.production(), - broker.bootstrapServers(), - broker.enableIdempotence(), - broker.acks(), - broker.maxInFlightRequestsPerConnection(), - broker.deliveryTimeout(), - broker.enableAutoCommit(), - broker.consumerGroup(), - broker.tlsEnabled(), - broker.authenticationEnabled()); - } - - private static RabbitBrokerProfile toRabbitProfile(String name, BrokerSettings broker) { - if (broker.addresses().isEmpty()) { - throw configurationError( - key("brokers", name, "addresses"), - "a RabbitMQ broker needs at least one address; a client with none defaults to " - + "localhost and connects as guest"); - } - return new RabbitBrokerProfile( - name, - broker.stable(), - broker.production(), - broker.addresses(), - broker.publisherConfirms(), - broker.publisherReturns(), - broker.mandatory(), - broker.confirmTimeout(), - broker.autoAck(), - broker.prefetch(), - broker.quorumQueues(), - broker.tlsEnabled(), - broker.authenticationEnabled()); } private DestinationProfile toProfile( diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationKeyValidator.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationKeyValidator.java index fdc2779..84e9baa 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationKeyValidator.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationKeyValidator.java @@ -108,6 +108,13 @@ public final class MessagingConfigurationKeyValidator implements InitializingBea } }); + for (String key : keysUnder(MessagingSettings.PREFIX + ".admin.")) { + String leaf = key.substring((MessagingSettings.PREFIX + ".admin.").length()); + if (!"enabled".equals(leaf)) { + rejected.add("%s binds nothing; admin entries accept [enabled]".formatted(key)); + } + } + if (rejected.isEmpty()) { return; } diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingCoreAutoConfiguration.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingCoreAutoConfiguration.java index 89c155b..81b0602 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingCoreAutoConfiguration.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingCoreAutoConfiguration.java @@ -265,6 +265,28 @@ public class MessagingCoreAutoConfiguration { return new CardinalityGuard(); } + /** + * Binds the platform observation seam to Micrometer when a registry is available. + * + *

Narrow tests and non-observed adopters may omit Micrometer entirely. A normal Boot runtime + * with Actuator contributes a registry, in which case publish outcomes must not fall back to the + * no-op observation constructor. + * + * @param registry the Micrometer registry + * @param guard the bounded-cardinality guard + * @param redactor the diagnostics redactor + * @return the messaging metrics binding + */ + @Bean + @ConditionalOnBean(io.micrometer.core.instrument.MeterRegistry.class) + @ConditionalOnMissingBean(dev.caskeleton.messaging.observation.MessagingObservation.class) + public dev.caskeleton.messaging.observation.MessagingObservation messagingObservation( + io.micrometer.core.instrument.MeterRegistry registry, + CardinalityGuard guard, + MessagingRedactor redactor) { + return new dev.caskeleton.messaging.observation.MessagingMetrics(registry, guard, redactor); + } + /** * Returns the blocking publish facade. * @@ -442,9 +464,16 @@ public class MessagingCoreAutoConfiguration { dev.caskeleton.messaging.schema.MessageCodecRegistry codecs, dev.caskeleton.messaging.policy.MessagingAdmissionController admission, MessagingRuntimeRegistry runtimes, - dev.caskeleton.messaging.transport.MessagingTransport transport) { + dev.caskeleton.messaging.transport.MessagingTransport transport, + ObjectProvider observation) { + dev.caskeleton.messaging.observation.MessagingObservation configured = + observation.getIfAvailable(); + if (configured == null) { + return new dev.caskeleton.messaging.runtime.DefaultMessagePublisher( + destinations, access, codecs, admission, runtimes, transport); + } return new dev.caskeleton.messaging.runtime.DefaultMessagePublisher( - destinations, access, codecs, admission, runtimes, transport); + destinations, access, codecs, admission, runtimes, transport, System::nanoTime, configured); } /** @@ -462,7 +491,8 @@ public class MessagingCoreAutoConfiguration { @Bean public org.springframework.beans.factory.InitializingBean messagingRuntimeInstallation( MessagingRuntimeRegistry runtimes, - ObjectProvider transport) { + ObjectProvider transport, + CompiledMessagingConfiguration compiled) { return () -> { dev.caskeleton.messaging.transport.MessagingTransport selected = transport.getIfAvailable(); if (selected == null) { @@ -472,9 +502,49 @@ public class MessagingCoreAutoConfiguration { // without a transport — and demanding one here would refuse that. return; } + + String runtimeName = logicalRuntimeName(selected, compiled); runtimes.install( new dev.caskeleton.messaging.runtime.TransportMessagingRuntime( - selected.brokerName(), 1L, selected)); + runtimeName, selected.generation(), selected)); }; } + + private static String logicalRuntimeName( + dev.caskeleton.messaging.transport.MessagingTransport selected, + CompiledMessagingConfiguration compiled) { + String configuredFamily = + switch (selected.brokerName()) { + case "kafka" -> BrokerSettings.KAFKA; + case "rabbit" -> BrokerSettings.RABBITMQ; + default -> selected.brokerName(); + }; + java.util.List configuredNames = + compiled.brokers().entrySet().stream() + .filter( + entry -> + entry.getValue().type() != null + && entry.getValue().type().equalsIgnoreCase(configuredFamily)) + .map(java.util.Map.Entry::getKey) + .sorted() + .toList(); + + if (configuredNames.isEmpty()) { + // Backward compatibility for applications that declare all profiles as beans and therefore + // have no app.messaging.brokers entries. Their destination profiles historically named the + // transport family directly. + return selected.brokerName(); + } + if (configuredNames.size() != 1) { + throw new IllegalStateException( + "the selected " + + selected.brokerName() + + " transport has one client/runtime but app.messaging.brokers declares " + + configuredNames.size() + + " logical brokers " + + configuredNames + + "; configure exactly one logical broker for the selected transport"); + } + return configuredNames.getFirst(); + } } diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingPlatformRootAutoConfiguration.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingPlatformRootAutoConfiguration.java index a588035..8e3b816 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingPlatformRootAutoConfiguration.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingPlatformRootAutoConfiguration.java @@ -22,7 +22,8 @@ import org.springframework.context.annotation.Import; * *

{@code app.messaging.enabled=false} means no beans, no clients, no threads, and no bound * detail namespace. {@code MessagingStarterOffContractTest} holds that against a full context - * including this starter's imports and the vendor auto-configurations Spring Boot would contribute. + * including this starter's owned imports. Vendor auto-configuration is verified in its own runtime + * lanes. */ @AutoConfiguration @ConditionalOnProperty(prefix = MessagingSettings.PREFIX, name = "enabled", havingValue = "true") diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java index c93129d..789e1a5 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java @@ -43,10 +43,10 @@ public class MessagingProviderSelection { "rabbit", "com.rabbitmq.client.Channel"); /** Broker id to the configuration that assembles it. */ - static final Map> PROVIDER_CONFIGURATIONS = + static final Map PROVIDER_CONFIGURATIONS = Map.of( - "kafka", KafkaMessagingAutoConfiguration.class, - "rabbit", RabbitMessagingAutoConfiguration.class); + "kafka", "dev.caskeleton.messaging.autoconfigure.KafkaMessagingAutoConfiguration", + "rabbit", "dev.caskeleton.messaging.autoconfigure.RabbitMessagingAutoConfiguration"); /** * Broker ids that ship without a {@code MessagingTransport}, and why. @@ -144,7 +144,7 @@ public class MessagingProviderSelection { @Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { - return new String[] {PROVIDER_CONFIGURATIONS.get(selectedBroker(environment)).getName()}; + return new String[] {PROVIDER_CONFIGURATIONS.get(selectedBroker(environment))}; } } } diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/BatchPublisherTest.java b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/BatchPublisherTest.java index 625e904..ee8855a 100644 --- a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/BatchPublisherTest.java +++ b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/BatchPublisherTest.java @@ -136,6 +136,18 @@ class BatchPublisherTest { .join(); } + @Test + void closingTheBatchPublisherStopsItsDeadlineScheduler() { + var deadlines = new java.util.concurrent.ScheduledThreadPoolExecutor(1); + var publisher = + new DefaultBatchMessagePublisher( + scripted(List.of(Outcome.CONFIRM), new ArrayList<>()), () -> NOW, deadlines); + + publisher.close(); + + assertThat(deadlines.isShutdown()).isTrue(); + } + @Test void everyEntryGetsItsOwnResultKeyedByIndex() { BatchPublishResult result = diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingAutoConfigurationTest.java b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingAutoConfigurationTest.java index dcb22b1..ba6b2c7 100644 --- a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingAutoConfigurationTest.java +++ b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingAutoConfigurationTest.java @@ -55,6 +55,49 @@ class MessagingAutoConfigurationTest { .hasSingleBean(GracefulShutdownCoordinator.class)); } + @Test + void installsSelectedTransportUnderConfiguredLogicalBrokerName() { + new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(MessagingCoreAutoConfiguration.class)) + .withUserConfiguration( + PublisherConfiguration.class, LogicalBrokerRuntimeConfiguration.class) + .withPropertyValues( + "app.messaging.brokers.kafka-primary.type=kafka", + "app.messaging.brokers.kafka-primary.bootstrap-servers[0]=broker-1:9092") + .run( + context -> { + assertThat(context).hasNotFailed(); + dev.caskeleton.messaging.transport.MessagingRuntimeRegistry runtimes = + context.getBean( + dev.caskeleton.messaging.transport.MessagingRuntimeRegistry.class); + + try (dev.caskeleton.messaging.transport.MessagingRuntimeLease lease = + runtimes.acquire("kafka-primary")) { + assertThat(lease.runtime().brokerName()).isEqualTo("kafka-primary"); + assertThat(lease.runtime().transport().brokerName()).isEqualTo("kafka"); + } + }); + } + + @Test + void multipleLogicalBrokersFailInsteadOfSharingOnePhysicalTransport() { + new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(MessagingCoreAutoConfiguration.class)) + .withUserConfiguration( + PublisherConfiguration.class, LogicalBrokerRuntimeConfiguration.class) + .withPropertyValues( + "app.messaging.brokers.kafka-primary.type=kafka", + "app.messaging.brokers.kafka-primary.bootstrap-servers[0]=broker-1:9092", + "app.messaging.brokers.kafka-secondary.type=kafka", + "app.messaging.brokers.kafka-secondary.bootstrap-servers[0]=broker-2:9092") + .run( + context -> + assertThat(context) + .hasFailed() + .getFailure() + .hasMessageContaining("exactly one logical broker")); + } + @Test void experimentalAdaptersAndTheBridgeAreOffByDefault() { runner.run( @@ -116,6 +159,47 @@ class MessagingAutoConfigurationTest { .run(context -> assertThat(context).hasFailed()); } + @Configuration(proxyBeanMethods = false) + static class LogicalBrokerRuntimeConfiguration { + + @Bean + dev.caskeleton.messaging.transport.MessagingTransport messagingTransport() { + return new dev.caskeleton.messaging.transport.MessagingTransport() { + @Override + public java.util.concurrent.CompletionStage< + dev.caskeleton.messaging.transport.TransportPublishResult> + publish(dev.caskeleton.messaging.transport.TransportPublishRequest request) { + throw new UnsupportedOperationException("not used"); + } + + @Override + public dev.caskeleton.messaging.transport.TransportConsumerRegistration register( + dev.caskeleton.messaging.transport.TransportConsumerSpec spec) { + throw new UnsupportedOperationException("not used"); + } + + @Override + public dev.caskeleton.messaging.api.destination.DestinationCapabilities capabilities( + DestinationName destination) { + throw new UnsupportedOperationException("not used"); + } + + @Override + public String brokerName() { + return "kafka"; + } + + @Override + public long generation() { + return 1L; + } + + @Override + public void close() {} + }; + } + } + /** Supplies the publisher the facades and orchestrator depend on. */ @Configuration(proxyBeanMethods = false) static class PublisherConfiguration { @@ -177,7 +261,7 @@ class MessagingAutoConfigurationTest { base.kind(), base.physical(), base.schema(), - base.deliveryGuarantee(), + DeliveryGuarantee.AT_MOST_ONCE, base.orderingScope(), base.externalSideEffectGuarantee(), base.producer(), diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationBindingTest.java b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationBindingTest.java index bea9b56..437ca3f 100644 --- a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationBindingTest.java +++ b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingConfigurationBindingTest.java @@ -67,18 +67,15 @@ class MessagingConfigurationBindingTest { CompiledMessagingConfiguration compiled = context.getBean(CompiledMessagingConfiguration.class); - assertThat(compiled.kafkaBrokers()) - .singleElement() - .satisfies( - broker -> { - assertThat(broker.broker()).isEqualTo("kafka-primary"); - assertThat(broker.bootstrapServers()) - .containsExactly("broker-1:9093", "broker-2:9093"); - assertThat(broker.enableAutoCommit()).isFalse(); - }); - assertThat(compiled.rabbitBrokers()) - .singleElement() - .satisfies(broker -> assertThat(broker.quorumQueues()).isTrue()); + assertThat(compiled.brokers()).containsKeys("kafka-primary", "rabbit-primary"); + BrokerSettings kafka = compiled.brokers().get("kafka-primary"); + assertThat(kafka.type()).isEqualTo(BrokerSettings.KAFKA); + assertThat(kafka.bootstrapServers()) + .containsExactly("broker-1:9093", "broker-2:9093"); + assertThat(kafka.enableAutoCommit()).isFalse(); + BrokerSettings rabbit = compiled.brokers().get("rabbit-primary"); + assertThat(rabbit.type()).isEqualTo(BrokerSettings.RABBITMQ); + assertThat(rabbit.quorumQueues()).isTrue(); assertThat(compiled.security()) .singleElement() .satisfies( @@ -95,6 +92,20 @@ class MessagingConfigurationBindingTest { }); } + @Test + void aTypoInsideTheAdminSectionFailsStartupNamingTheKey() { + runner + .withPropertyValues(minimal()) + .withPropertyValues("app.messaging.admin.enable=true") + .run( + context -> + assertThat(context) + .hasFailed() + .getFailure() + .hasMessageContaining("app.messaging.admin.enable") + .hasMessageContaining("enabled")); + } + @Test void aTypoInsideABoundSectionFailsStartupNamingTheKey() { runner @@ -263,6 +274,7 @@ class MessagingConfigurationBindingTest { "app.messaging.destinations.order-events.kind=EVENT_STREAM", "app.messaging.destinations.order-events.physical.topic=order.events.v1", "app.messaging.destinations.order-events.schema.message-types[0]=order.created", + "app.messaging.destinations.order-events.guarantees.delivery=AT_MOST_ONCE", }; } diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingMigrationNamespaceTest.java b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingMigrationNamespaceTest.java new file mode 100644 index 0000000..6cd3e52 --- /dev/null +++ b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingMigrationNamespaceTest.java @@ -0,0 +1,79 @@ +package dev.caskeleton.messaging.autoconfigure; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.net.JarURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.junit.jupiter.api.Test; + +/** + * Keeps every messaging reliability migration in one collision-free Flyway version namespace. + * + *

The starter ships both JDBC reliability modules, so this test inspects the same combined + * runtime classpath an adopter receives rather than certifying each module in isolation. + */ +class MessagingMigrationNamespaceTest { + + private static final String LOCATION = "db/migration/messaging"; + private static final Pattern VERSIONED = Pattern.compile("V(\\d+)__.+\\.sql"); + + @Test + void combinedMessagingClasspathHasUniqueReservedFlywayVersions() throws Exception { + List migrations = migrationsOnCombinedClasspath(); + + assertThat(migrations) + .as("both messaging JDBC modules must contribute migrations to the assembled starter") + .hasSizeGreaterThanOrEqualTo(5); + + Set versions = new HashSet<>(); + for (String migration : migrations) { + Matcher match = VERSIONED.matcher(migration); + assertThat(match.matches()).as("%s must be a versioned Flyway migration", migration).isTrue(); + long version = Long.parseLong(match.group(1)); + assertThat(version) + .as("%s must stay in the messaging-reserved version range", migration) + .isBetween(1000L, 1999L); + assertThat(versions.add(version)) + .as("Flyway version %s is duplicated across the assembled messaging modules", version) + .isTrue(); + } + } + + private static List migrationsOnCombinedClasspath() throws IOException { + List names = new ArrayList<>(); + Enumeration roots = + MessagingMigrationNamespaceTest.class.getClassLoader().getResources(LOCATION); + while (roots.hasMoreElements()) { + URL root = roots.nextElement(); + if ("file".equals(root.getProtocol())) { + java.io.File[] files = + new java.io.File(java.net.URI.create(root.toString())) + .listFiles((dir, name) -> name.endsWith(".sql")); + if (files != null) { + for (java.io.File file : files) { + names.add(file.getName()); + } + } + } else if ("jar".equals(root.getProtocol())) { + JarURLConnection connection = (JarURLConnection) root.openConnection(); + try (java.util.jar.JarFile jar = connection.getJarFile()) { + jar.stream() + .map(java.util.jar.JarEntry::getName) + .filter(name -> name.startsWith(LOCATION + "/")) + .filter(name -> name.endsWith(".sql")) + .map(name -> name.substring(name.lastIndexOf('/') + 1)) + .forEach(names::add); + } + } + } + return names.stream().sorted().toList(); + } +} diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingOutboxRelayLifecycleTest.java b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingOutboxRelayLifecycleTest.java index 4f283df..6527539 100644 --- a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingOutboxRelayLifecycleTest.java +++ b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingOutboxRelayLifecycleTest.java @@ -133,21 +133,11 @@ class MessagingOutboxRelayLifecycleTest { throw new UnsupportedOperationException("not used by this test"); } - @Override - public void markPublished(MessageId messageId, Instant now) { - throw new UnsupportedOperationException("not used by this test"); - } - @Override public OutboxTransitionResult markPublished(OutboxLease lease, Instant now) { throw new UnsupportedOperationException("not used by this test"); } - @Override - public void markAmbiguous(MessageId messageId, String failureCode, Instant now) { - throw new UnsupportedOperationException("not used by this test"); - } - @Override public OutboxTransitionResult markAmbiguous( OutboxLease lease, String failureCode, Instant now) { @@ -165,21 +155,11 @@ class MessagingOutboxRelayLifecycleTest { throw new UnsupportedOperationException("not used by this test"); } - @Override - public void markFailed(MessageId messageId, String failureCode, Instant now) { - throw new UnsupportedOperationException("not used by this test"); - } - @Override public OutboxTransitionResult markFailed(OutboxLease lease, String failureCode, Instant now) { throw new UnsupportedOperationException("not used by this test"); } - @Override - public void releaseLease(MessageId messageId) { - throw new UnsupportedOperationException("not used by this test"); - } - @Override public OutboxTransitionResult releaseLease(OutboxLease lease) { throw new UnsupportedOperationException("not used by this test"); diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingStarterOffContractTest.java b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingStarterOffContractTest.java index 2d4f7c4..033fb0d 100644 --- a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingStarterOffContractTest.java +++ b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingStarterOffContractTest.java @@ -5,9 +5,9 @@ import static org.assertj.core.api.Assertions.assertThat; import dev.caskeleton.messaging.api.MessageEnvelope; import dev.caskeleton.messaging.api.destination.MessageDestination; import dev.caskeleton.messaging.api.publish.MessagePublisher; -import dev.caskeleton.messaging.schema.EncodedMessagePublisher; import dev.caskeleton.messaging.api.publish.PublishOptions; import dev.caskeleton.messaging.api.publish.PublishResult; +import dev.caskeleton.messaging.schema.EncodedMessagePublisher; import java.util.Set; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; @@ -180,18 +180,51 @@ class MessagingStarterOffContractTest { context -> { assertThat(context) .as( - "this asserted the opposite, with the note that C3 would invert it rather than " - + "delete it. Every policy bean was in place and the platform still could " - + "not publish: no configuration produced a MessagePublisher, so " - + "DeadLetterOrchestrator had nothing to depend on. DefaultMessagePublisher " - + "existed in messaging-runtime-core the whole time — the starter did not " - + "depend on that leaf.") + "this asserted the opposite, with the note that C3 would invert it rather" + + " than delete it. Every policy bean was in place and the platform still" + + " could not publish: no configuration produced a MessagePublisher, so" + + " DeadLetterOrchestrator had nothing to depend on." + + " DefaultMessagePublisher existed in messaging-runtime-core the whole" + + " time — the starter did not depend on that leaf.") .hasNotFailed(); assertThat(context).hasSingleBean(MessagePublisher.class); assertThat(context).hasSingleBean(EncodedMessagePublisher.class); }); } + @Test + @DisplayName("a selected publisher uses the Micrometer observation bean when a registry exists") + void selectedPublisherIsObserved() { + runner + .withBean( + io.micrometer.core.instrument.MeterRegistry.class, + io.micrometer.core.instrument.simple.SimpleMeterRegistry::new) + .withPropertyValues( + "app.messaging.enabled=true", + "app.messaging.broker=kafka", + "spring.kafka.bootstrap-servers=localhost:9092") + .run( + context -> { + assertThat(context) + .hasSingleBean(dev.caskeleton.messaging.observation.MessagingObservation.class); + Object publisher = context.getBean(MessagePublisher.class); + assertThat(publisher) + .isInstanceOf(dev.caskeleton.messaging.runtime.DefaultMessagePublisher.class); + + try { + java.lang.reflect.Field observation = + publisher.getClass().getDeclaredField("observation"); + observation.setAccessible(true); + assertThat(observation.get(publisher)) + .isSameAs( + context.getBean( + dev.caskeleton.messaging.observation.MessagingObservation.class)); + } catch (ReflectiveOperationException failure) { + throw new LinkageError(failure.getMessage(), failure); + } + }); + } + @Test @DisplayName("a selected broker with no address fails at startup, not at the first publish") void aSelectedBrokerWithNoAddressFailsAtStartup() { diff --git a/messaging/messaging-spring-cloud-stream-bridge/build.gradle b/messaging/messaging-spring-cloud-stream-bridge/build.gradle index e9bd8ef..d104567 100644 --- a/messaging/messaging-spring-cloud-stream-bridge/build.gradle +++ b/messaging/messaging-spring-cloud-stream-bridge/build.gradle @@ -7,5 +7,4 @@ dependencies { api project(':messaging:messaging-policy') api project(':messaging:messaging-transport-spi') - implementation 'org.springframework:spring-context' } diff --git a/messaging/messaging-spring-cloud-stream-bridge/gradle.lockfile b/messaging/messaging-spring-cloud-stream-bridge/gradle.lockfile index 4c95da8..e2c9585 100644 --- a/messaging/messaging-spring-cloud-stream-bridge/gradle.lockfile +++ b/messaging/messaging-spring-cloud-stream-bridge/gradle.lockfile @@ -29,12 +29,9 @@ com.puppycrawl.tools:checkstyle:13.5.0=checkstyle commons-beanutils:commons-beanutils:1.11.0=checkstyle commons-collections:commons-collections:3.2.2=checkstyle commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath @@ -61,7 +58,7 @@ org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle org.codehaus.plexus:plexus-utils:3.3.0=checkstyle org.dom4j:dom4j:2.2.0=spotbugs org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath +org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath @@ -83,10 +80,5 @@ org.reflections:reflections:0.10.2=checkstyle org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework:spring-aop:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-context:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-expression:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty= +empty=compileClasspath,runtimeClasspath diff --git a/messaging/messaging-spring-cloud-stream-bridge/src/main/java/dev/caskeleton/messaging/streambridge/SpringCloudStreamPublisherBridge.java b/messaging/messaging-spring-cloud-stream-bridge/src/main/java/dev/caskeleton/messaging/streambridge/SpringCloudStreamPublisherBridge.java index 7e2b68d..059144f 100644 --- a/messaging/messaging-spring-cloud-stream-bridge/src/main/java/dev/caskeleton/messaging/streambridge/SpringCloudStreamPublisherBridge.java +++ b/messaging/messaging-spring-cloud-stream-bridge/src/main/java/dev/caskeleton/messaging/streambridge/SpringCloudStreamPublisherBridge.java @@ -15,7 +15,14 @@ import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; /** - * Sends through a Spring Cloud Stream output binding and reports what that actually proves. + * Framework-neutral publish evidence bridge for a future Spring Cloud Stream adapter. + * + *

Despite the historical module/class name, this type does not itself depend on Spring Cloud + * Stream and does not auto-configure {@code StreamBridge}. A product integrating Spring Cloud + * Stream supplies the {@link ChannelSend} seam explicitly. Keeping that limitation in the type + * contract prevents this module from being mistaken for a shipped Spring Cloud Stream integration. + * + *

Sends through a Spring Cloud Stream output binding and reports what that actually proves. * *

The result is deliberately {@code AMBIGUOUS} rather than {@code CONFIRMED}. A Stream {@code * send} returns a boolean from the message channel — it says the binder accepted the message, not diff --git a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerCertificationEvidence.java b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerCertificationEvidence.java index ce02606..360e69c 100644 --- a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerCertificationEvidence.java +++ b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerCertificationEvidence.java @@ -14,9 +14,9 @@ import java.util.Objects; * then tells an adopter that connection-cut and confirm-timeout are certified when neither has ever * run. * - *

This record is what a lane emits after running. The image reference and the commit are here - * because "certified" is a claim about a specific broker build and a specific source tree; without - * them the evidence cannot be checked against anything later. + *

This record is what a lane emits after running. The image reference, commit and observation + * time are provenance: they identify the run for audit/replay. The certification equality gate + * compares the behavioral claim fields and deliberately does not use commit/time as freshness keys. * *

{@link #toJson()} and {@link #fromJson(String)} are the same statement in both directions: the * certification lane writes a line per scenario it proved and the compatibility matrix reads those diff --git a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerFailureMatrix.java b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerFailureMatrix.java index acb7d50..5f27cdc 100644 --- a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerFailureMatrix.java +++ b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/BrokerFailureMatrix.java @@ -86,6 +86,26 @@ public final class BrokerFailureMatrix { .anyMatch(scenario -> coverageOf(adapter, scenario) == Coverage.LIVE_BROKER); } + /** + * Reports whether every scenario is backed by live-broker evidence or an explicitly approved gap. + * + *

This is the Stable certification predicate. A single live scenario is not certification, and + * an absent scenario is not silently converted into an approved exception. + * + * @param adapter the adapter module name + * @param approvedGaps gaps reviewed and accepted independently of this matrix + * @return true when every scenario is explained by evidence or an approved gap + */ + public boolean hasCertificationCoverage( + String adapter, java.util.Set approvedGaps) { + Objects.requireNonNull(approvedGaps, "approvedGaps must not be null"); + return NetworkFaultScenario.all().stream() + .allMatch( + scenario -> + coverageOf(adapter, scenario) == Coverage.LIVE_BROKER + || approvedGaps.contains(scenario)); + } + /** * Reports whether an adapter covers every scenario. * diff --git a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CertifiedEvidence.java b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CertifiedEvidence.java index 6d7f614..423bd4b 100644 --- a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CertifiedEvidence.java +++ b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CertifiedEvidence.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -33,6 +34,9 @@ public final class CertifiedEvidence { private static final List RECORDED = load(); + private static final Map> APPROVED_GAPS = + Map.of("messaging-kafka", Set.of(NetworkFaultScenario.CONNECTION_REFUSED)); + private CertifiedEvidence() {} /** @@ -44,6 +48,17 @@ public final class CertifiedEvidence { return RECORDED; } + /** + * Returns gaps that were deliberately accepted after review rather than inferred from missing + * evidence. + * + * @param adapter the adapter module name + * @return the explicit approved gaps for that adapter + */ + public static Set approvedGaps(String adapter) { + return APPROVED_GAPS.getOrDefault(adapter, Set.of()); + } + /** * Returns the scenarios an adapter has no evidence for. * diff --git a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CompatibilityMatrix.java b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CompatibilityMatrix.java index 0eb721b..13d7486 100644 --- a/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CompatibilityMatrix.java +++ b/messaging/messaging-testkit/src/main/java/dev/caskeleton/messaging/testkit/CompatibilityMatrix.java @@ -58,7 +58,8 @@ public final class CompatibilityMatrix { * @return true when {@link CertifiedEvidence} has live-broker evidence for this adapter */ public boolean hasLiveBrokerCertification() { - return BrokerFailureMatrix.from(CertifiedEvidence.recorded()).hasLiveBrokerCoverage(adapter); + return BrokerFailureMatrix.from(CertifiedEvidence.recorded()) + .hasCertificationCoverage(adapter, CertifiedEvidence.approvedGaps(adapter)); } public Entry { diff --git a/messaging/messaging-testkit/src/test/java/dev/caskeleton/messaging/testkit/CompatibilityMatrixTest.java b/messaging/messaging-testkit/src/test/java/dev/caskeleton/messaging/testkit/CompatibilityMatrixTest.java index c2bd66d..f126796 100644 --- a/messaging/messaging-testkit/src/test/java/dev/caskeleton/messaging/testkit/CompatibilityMatrixTest.java +++ b/messaging/messaging-testkit/src/test/java/dev/caskeleton/messaging/testkit/CompatibilityMatrixTest.java @@ -46,17 +46,27 @@ class CompatibilityMatrixTest { } @Test - void aCertificationClaimCannotBeMadeWithoutEvidence() { + void oneLiveScenarioCannotSatisfyAStableCertification() { + String adapter = "messaging-partial"; + BrokerFailureMatrix partial = + new BrokerFailureMatrix() + .record( + adapter, + NetworkFaultScenario.all().get(0), + BrokerFailureMatrix.Coverage.LIVE_BROKER); + + assertThat(partial.hasCertificationCoverage(adapter, java.util.Set.of())).isFalse(); + } + + @Test + void everyStableAdapterHasOnlyExplicitlyApprovedEvidenceGaps() { assertThat(CompatibilityMatrix.entries().values()) + .filteredOn(entry -> entry.tier() == CompatibilityMatrix.Tier.STABLE) .allSatisfy( entry -> - assertThat(entry.hasLiveBrokerCertification()) - .as( - "%s claims certification, so a lane must have produced evidence", - entry.adapter()) - .isEqualTo( - BrokerFailureMatrix.from(CertifiedEvidence.recorded()) - .hasLiveBrokerCoverage(entry.adapter()))); + assertThat(CertifiedEvidence.approvedGaps(entry.adapter())) + .containsExactlyInAnyOrderElementsOf( + CertifiedEvidence.knownGaps(entry.adapter()))); } @Test