Skip to content

Commit

Permalink
Using upstream axon server 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
trimoq committed Jul 19, 2022
1 parent c6140dd commit b51f8a9
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 33 deletions.
2 changes: 1 addition & 1 deletion reset-handler/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.3'
services:
axonserver:
image: axoniq/axonserver
image: 'axoniq/axonserver:4.6.0-dev'
hostname: axonserver
ports:
- '8024:8024'
Expand Down
4 changes: 2 additions & 2 deletions reset-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>io.axoniq</groupId>
<artifactId>axonserver-connector-java</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ public interface EventProcessorService {

Mono<Void> reset(String processorName);

// Mono<Void> awaitTermination(String processorName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -100,7 +102,6 @@ public Mono<Void> 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<Void> awaitTermination(String processorName) {
return webClient.get()
.uri("/v1/components/{component}/processors?context={context}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions reset-handler/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ axon:
axonserver:
context: "default"
component-name: "component"
http-url: "http://127.0.0.1:8024"

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 16 additions & 4 deletions reset-handler/src/test/java/io/axoniq/controller/ResetE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -84,6 +95,7 @@ void createEvents(){
.expectStatus()
.isOk();
}
waitForAS();
verify(projection, times(10)).on(any());
}

Expand Down
5 changes: 5 additions & 0 deletions reset-handler/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
axon:
axonserver:
context: "default"
component-name: "component"
http-url: "http://127.0.0.1:8024"
7 changes: 2 additions & 5 deletions reset-handler/src/test/resources/compose-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
version: '3.3'
services:
axonserver:
image: hackyaxonserver
hostname: axonserver
ports:
- '8024:8024'
- '8124:8124'
image: 'axoniq/axonserver:4.6.0-dev'
hostname: axonserver

0 comments on commit b51f8a9

Please sign in to comment.