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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<ExecutionGraphQlResponse>` 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();
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
Reference in New Issue
Block a user