From 66e935f92eb1058c46485f25110eed153005a257 Mon Sep 17 00:00:00 2001 From: abilan Date: Wed, 14 Jun 2023 14:13:18 -0400 Subject: [PATCH] Fix graphql.adoc and optimize Debezium tests * Fix some typos and update to the actual types in the `graphql.adoc` * Don't use `@Container` in the `DebeziumMySqlTestContainer`, but rather start it manually in the `@BeforeAll` and let one container to survive between tests. The Ryuk container then takes care about other containers on JVM exist --- .../debezium/DebeziumMySqlTestContainer.java | 21 ++++++++++++------- src/reference/asciidoc/graphql.adoc | 10 ++++----- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/spring-integration-debezium/src/test/java/org/springframework/integration/debezium/DebeziumMySqlTestContainer.java b/spring-integration-debezium/src/test/java/org/springframework/integration/debezium/DebeziumMySqlTestContainer.java index 3a979854b5..be72be43ad 100644 --- a/spring-integration-debezium/src/test/java/org/springframework/integration/debezium/DebeziumMySqlTestContainer.java +++ b/spring-integration-debezium/src/test/java/org/springframework/integration/debezium/DebeziumMySqlTestContainer.java @@ -19,9 +19,9 @@ package org.springframework.integration.debezium; import java.util.Properties; import java.util.UUID; +import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; -import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; /** @@ -35,13 +35,18 @@ public interface DebeziumMySqlTestContainer { int EXPECTED_DB_TX_COUNT = 52; - @Container - GenericContainer DEBEZIUM_MYSQL = new GenericContainer<>("debezium/example-mysql:2.2.0.Final") - .withExposedPorts(3306) - .withEnv("MYSQL_ROOT_PASSWORD", "debezium") - .withEnv("MYSQL_USER", "mysqluser") - .withEnv("MYSQL_PASSWORD", "mysqlpw") - .waitingFor(new LogMessageWaitStrategy().withRegEx(".*port: 3306 MySQL Community Server - GPL.*.")); + GenericContainer DEBEZIUM_MYSQL = + new GenericContainer<>("debezium/example-mysql:2.2.0.Final") + .withExposedPorts(3306) + .withEnv("MYSQL_ROOT_PASSWORD", "debezium") + .withEnv("MYSQL_USER", "mysqluser") + .withEnv("MYSQL_PASSWORD", "mysqlpw") + .waitingFor(new LogMessageWaitStrategy().withRegEx(".*port: 3306 MySQL Community Server - GPL.*.")); + + @BeforeAll + static void startContainer() { + DEBEZIUM_MYSQL.start(); + } static int mysqlPort() { return DEBEZIUM_MYSQL.getMappedPort(3306); diff --git a/src/reference/asciidoc/graphql.adoc b/src/reference/asciidoc/graphql.adoc index f5c17949dd..221e272d69 100644 --- a/src/reference/asciidoc/graphql.adoc +++ b/src/reference/asciidoc/graphql.adoc @@ -27,13 +27,13 @@ compile "org.springframework.integration:spring-integration-graphql:{project-ver === GraphQL Outbound Gateway The `GraphQlMessageHandler` is an `AbstractReplyProducingMessageHandler` extension representing an outbound gateway contract to perform GraphQL `query`, `mutation` or `subscription` operation and produce their result. -It requires a `org.springframework.graphql.ExecutionGraphQlService` for execution of `operation`, which can be configured statically or via SpEL expression against a request message. +It requires a `org.springframework.graphql.ExecutionGraphQlService` for execution of an `operation`, which can be configured statically or via SpEL expression against a request message. The `operationName` is optional and also can be configured statically or via SpEL expression. The `variablesExpression` is also optional and used for parametrized operations. The `locale` is optional and used for operation execution context in the https://www.graphql-java.com/[GraphQL Java] library. The `executionId` can be configured via SpEL expression and defaults to `id` header of the request message. -If the payload of request message is an instance of `ExecutionGraphQlRequest`, then there's no any setup actions are performed in the `GraphQlMessageHandler` and such an input is used as is for the `ExecutionGraphQlService.execute()`. +If the payload of the request message is an instance of `ExecutionGraphQlRequest`, then there's no any setup actions are performed in the `GraphQlMessageHandler` and such an input is used as is for the `ExecutionGraphQlService.execute()`. Otherwise, the `operation`, `operationName`, `variables` and `executionId` are determined against request message using SpEL expressions mentioned above. The `GraphQlMessageHandler` is a reactive streams component and produces a `Mono` reply as a result of the `ExecutionGraphQlService.execute(ExecutionGraphQlRequest)`. @@ -87,15 +87,15 @@ AnnotatedControllerConfigurer annotatedDataFetcherConfigurer() { ==== The special treatment should be applied for the result of a subscription operation. -In this case the `RequestOutput.getData()` returns a `SubscriptionPublisher` which has to subscribed and processed manually. +In this case the `ExecutionGraphQlResponse.getData()` returns a `SubscriptionPublisher` which has to subscribed and processed manually. Or it can be flat-mapped via plain service activator to the reply for the `FluxMessageChannel`: ==== [source, java] ---- @ServiceActivator(inputChannel = "graphQlResultChannel", outputChannel="graphQlSubscriptionChannel") -public SubscriptionPublisher obtainSubscriptionResult(RequestOutput output) { - return output.getData(0); +public SubscriptionPublisher obtainSubscriptionResult(ExecutionGraphQlResponse graphQlResponse) { + return graphQlResponse.getData(); } ---- ====