diff --git a/reset-handler/docker-compose.yml b/reset-handler/docker-compose.yml index 2c9a3859..d41a4cdd 100644 --- a/reset-handler/docker-compose.yml +++ b/reset-handler/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.3' services: axonserver: - image: axoniq/axonserver + image: 'axoniq/axonserver:4.6.0-dev' hostname: axonserver ports: - '8024:8024' diff --git a/reset-handler/pom.xml b/reset-handler/pom.xml index 5a4f2ef6..63e5a855 100644 --- a/reset-handler/pom.xml +++ b/reset-handler/pom.xml @@ -18,12 +18,12 @@ org.axonframework axon-spring-boot-starter - 4.6.0-SNAPSHOT + 4.5.14 io.axoniq axonserver-connector-java - 4.6.0-SNAPSHOT + 4.6.1 org.springframework.boot diff --git a/reset-handler/src/main/java/io/axoniq/config/ConfigBasedAdminChannel.java b/reset-handler/src/main/java/io/axoniq/config/ConfigBasedAdminChannel.java index db3f8228..039aefa2 100644 --- a/reset-handler/src/main/java/io/axoniq/config/ConfigBasedAdminChannel.java +++ b/reset-handler/src/main/java/io/axoniq/config/ConfigBasedAdminChannel.java @@ -1,8 +1,7 @@ package io.axoniq.config; -import io.axoniq.axonserver.connector.AxonServerConnectionFactory; import io.axoniq.axonserver.connector.admin.AdminChannel; -import org.springframework.beans.factory.annotation.Value; +import org.axonframework.axonserver.connector.AxonServerConnectionManager; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; @@ -12,21 +11,13 @@ */ @Component public class ConfigBasedAdminChannel { - - private final String contextName; - private final String componentName; - - public ConfigBasedAdminChannel(@Value("${axon.axonserver.context}") String contextName, - @Value("${axon.axonserver.component-name}") String componentName){ - this.contextName = contextName; - this.componentName = componentName; + public ConfigBasedAdminChannel(AxonServerConnectionManager axonServerConnectionManager){ + this.axonServerConnectionManager = axonServerConnectionManager; } + private final AxonServerConnectionManager axonServerConnectionManager; @Bean public AdminChannel adminChannel() { - return AxonServerConnectionFactory.forClient(componentName) - .build() - .connect(contextName) - .adminChannel(); + return axonServerConnectionManager.getConnection().adminChannel(); } } diff --git a/reset-handler/src/main/java/io/axoniq/service/EventProcessorService.java b/reset-handler/src/main/java/io/axoniq/service/EventProcessorService.java index 7536f8cd..145dc694 100644 --- a/reset-handler/src/main/java/io/axoniq/service/EventProcessorService.java +++ b/reset-handler/src/main/java/io/axoniq/service/EventProcessorService.java @@ -9,5 +9,4 @@ public interface EventProcessorService { Mono reset(String processorName); -// Mono awaitTermination(String processorName); } diff --git a/reset-handler/src/main/java/io/axoniq/service/RestEventProcessorService.java b/reset-handler/src/main/java/io/axoniq/service/RestEventProcessorService.java index 0549afbe..9deb72d5 100644 --- a/reset-handler/src/main/java/io/axoniq/service/RestEventProcessorService.java +++ b/reset-handler/src/main/java/io/axoniq/service/RestEventProcessorService.java @@ -31,9 +31,11 @@ public class RestEventProcessorService implements EventProcessorService { public RestEventProcessorService(@Value("${axon.axonserver.context}") String context, @Value("${axon.axonserver.component-name}") String component, - TokenStore tokenStore, Configuration configuration) { + @Value("${axon.axonserver.http-url}") String httpUrl, + TokenStore tokenStore, + Configuration configuration) { this.configuration = configuration; - this.webClient = WebClient.create("http://localhost:8024"); + this.webClient = WebClient.create(httpUrl!=null?httpUrl:"http://localhost:8024"); this.contextSupplier = () -> context; this.componentSupplier = () -> component; this.tokenStoreIdSupplier = () -> tokenStore.retrieveStorageIdentifier().get(); @@ -100,7 +102,6 @@ public Mono reset(String processorName) { * @param processorName Name of the processor to wait for termination. * @return Returns a Mono that completes when processor is terminated. */ -// @terminatedOverride public Mono awaitTermination(String processorName) { return webClient.get() .uri("/v1/components/{component}/processors?context={context}", diff --git a/reset-handler/src/main/java/io/axoniq/service/ServerConnectorEventProcessorService.java b/reset-handler/src/main/java/io/axoniq/service/ServerConnectorEventProcessorService.java index 295b2e52..487202a3 100644 --- a/reset-handler/src/main/java/io/axoniq/service/ServerConnectorEventProcessorService.java +++ b/reset-handler/src/main/java/io/axoniq/service/ServerConnectorEventProcessorService.java @@ -22,7 +22,8 @@ public class ServerConnectorEventProcessorService implements EventProcessorServi private final Configuration configuration; private final AdminChannel adminChannel; - public ServerConnectorEventProcessorService(Configuration configuration, AdminChannel adminChannel) { + public ServerConnectorEventProcessorService(Configuration configuration, + AdminChannel adminChannel) { this.configuration = configuration; this.adminChannel = adminChannel; } diff --git a/reset-handler/src/main/resources/application.yml b/reset-handler/src/main/resources/application.yml index 03b21bbf..9f213495 100644 --- a/reset-handler/src/main/resources/application.yml +++ b/reset-handler/src/main/resources/application.yml @@ -2,4 +2,5 @@ axon: axonserver: context: "default" component-name: "component" + http-url: "http://127.0.0.1:8024" diff --git a/reset-handler/src/test/java/io/axoniq/ResetServiceIntegrationTest.java b/reset-handler/src/test/java/io/axoniq/ResetServiceIntegrationTest.java index 74787ee9..fcf0500b 100644 --- a/reset-handler/src/test/java/io/axoniq/ResetServiceIntegrationTest.java +++ b/reset-handler/src/test/java/io/axoniq/ResetServiceIntegrationTest.java @@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; @@ -40,15 +42,27 @@ public class ResetServiceIntegrationTest { private static final String EVENT_PROCESSOR_NAME="io.axoniq"; + private static final int HTTP_PORT = 8024; + private static final int GRPC_PORT = 8124; + @ClassRule @Container public static DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/compose-test.yml")) - .withExposedService("axonserver", 8024, Wait.forListeningPort()) - .withExposedService("axonserver", 8124, Wait.forListeningPort()) + .withExposedService("axonserver", HTTP_PORT, Wait.forListeningPort()) + .withExposedService("axonserver", GRPC_PORT, Wait.forListeningPort()) .waitingFor("axonserver", Wait.forLogMessage(".*Started AxonServer in .*",1)); + @DynamicPropertySource + public static void properties(DynamicPropertyRegistry registry) { + + int grpcPort = environment.getServicePort("axonserver", GRPC_PORT); + int httpPort = environment.getServicePort("axonserver", HTTP_PORT); + registry.add("axon.axonserver.servers", () -> "localhost:"+grpcPort); + registry.add("axon.axonserver.http-url", () -> "http://localhost:"+httpPort); + + } @BeforeEach void prepare(){ createEvents(); diff --git a/reset-handler/src/test/java/io/axoniq/controller/ResetE2ETest.java b/reset-handler/src/test/java/io/axoniq/controller/ResetE2ETest.java index ba9b3353..31e17287 100644 --- a/reset-handler/src/test/java/io/axoniq/controller/ResetE2ETest.java +++ b/reset-handler/src/test/java/io/axoniq/controller/ResetE2ETest.java @@ -8,6 +8,8 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.web.reactive.server.WebTestClient; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; @@ -24,8 +26,8 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ResetE2ETest { - final static int PORT_A = 8024; - final static int PORT_B = 8124; + private static final int HTTP_PORT = 8024; + private static final int GRPC_PORT = 8124; @LocalServerPort private int port; @@ -42,10 +44,19 @@ public class ResetE2ETest { @Container public static DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/compose-test.yml")) - .withExposedService("axonserver", PORT_A, Wait.forListeningPort()) - .withExposedService("axonserver", PORT_B, Wait.forListeningPort()) + .withExposedService("axonserver", HTTP_PORT, Wait.forListeningPort()) + .withExposedService("axonserver", GRPC_PORT, Wait.forListeningPort()) .waitingFor("axonserver", Wait.forLogMessage(".*Started AxonServer in .*",1)); + @DynamicPropertySource + public static void properties(DynamicPropertyRegistry registry) { + int grpcPort = environment.getServicePort("axonserver", GRPC_PORT); + int httpPort = environment.getServicePort("axonserver", HTTP_PORT); + + registry.add("axon.axonserver.servers", () -> "localhost:"+grpcPort); + registry.add("axon.axonserver.http-url", () -> "http://localhost:"+httpPort); + + } @Test void testEventsAreCreated(){ prepareIntegrationTest(); @@ -84,6 +95,7 @@ void createEvents(){ .expectStatus() .isOk(); } + waitForAS(); verify(projection, times(10)).on(any()); } diff --git a/reset-handler/src/test/resources/application.yml b/reset-handler/src/test/resources/application.yml new file mode 100644 index 00000000..699177e6 --- /dev/null +++ b/reset-handler/src/test/resources/application.yml @@ -0,0 +1,5 @@ +axon: + axonserver: + context: "default" + component-name: "component" + http-url: "http://127.0.0.1:8024" diff --git a/reset-handler/src/test/resources/compose-test.yml b/reset-handler/src/test/resources/compose-test.yml index d94b229a..a172bbc6 100644 --- a/reset-handler/src/test/resources/compose-test.yml +++ b/reset-handler/src/test/resources/compose-test.yml @@ -1,8 +1,5 @@ version: '3.3' services: axonserver: - image: hackyaxonserver - hostname: axonserver - ports: - - '8024:8024' - - '8124:8124' \ No newline at end of file + image: 'axoniq/axonserver:4.6.0-dev' + hostname: axonserver \ No newline at end of file