Skip to content

Commit 477ec78

Browse files
committed
Using upstream axon server 4.6
1 parent c6140dd commit 477ec78

File tree

10 files changed

+53
-31
lines changed

10 files changed

+53
-31
lines changed

reset-handler/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3.3'
22
services:
33
axonserver:
4-
image: axoniq/axonserver
4+
image: 'axoniq/axonserver:4.6.0-dev'
55
hostname: axonserver
66
ports:
77
- '8024:8024'

reset-handler/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
<dependency>
1919
<groupId>org.axonframework</groupId>
2020
<artifactId>axon-spring-boot-starter</artifactId>
21-
<version>4.6.0-SNAPSHOT</version>
21+
<version>4.5.14</version>
2222
</dependency>
2323
<dependency>
2424
<groupId>io.axoniq</groupId>
2525
<artifactId>axonserver-connector-java</artifactId>
26-
<version>4.6.0-SNAPSHOT</version>
26+
<version>4.6.1</version>
2727
</dependency>
2828
<dependency>
2929
<groupId>org.springframework.boot</groupId>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package io.axoniq.config;
22

3-
import io.axoniq.axonserver.connector.AxonServerConnectionFactory;
43
import io.axoniq.axonserver.connector.admin.AdminChannel;
5-
import org.springframework.beans.factory.annotation.Value;
4+
import org.axonframework.axonserver.connector.AxonServerConnectionManager;
65
import org.springframework.context.annotation.Bean;
76
import org.springframework.stereotype.Component;
87

@@ -12,21 +11,13 @@
1211
*/
1312
@Component
1413
public class ConfigBasedAdminChannel {
15-
16-
private final String contextName;
17-
private final String componentName;
18-
19-
public ConfigBasedAdminChannel(@Value("${axon.axonserver.context}") String contextName,
20-
@Value("${axon.axonserver.component-name}") String componentName){
21-
this.contextName = contextName;
22-
this.componentName = componentName;
14+
public ConfigBasedAdminChannel(AxonServerConnectionManager axonServerConnectionManager){
15+
this.axonServerConnectionManager = axonServerConnectionManager;
2316
}
17+
private final AxonServerConnectionManager axonServerConnectionManager;
2418

2519
@Bean
2620
public AdminChannel adminChannel() {
27-
return AxonServerConnectionFactory.forClient(componentName)
28-
.build()
29-
.connect(contextName)
30-
.adminChannel();
21+
return axonServerConnectionManager.getConnection().adminChannel();
3122
}
3223
}

reset-handler/src/main/java/io/axoniq/service/RestEventProcessorService.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ public class RestEventProcessorService implements EventProcessorService {
3131

3232
public RestEventProcessorService(@Value("${axon.axonserver.context}") String context,
3333
@Value("${axon.axonserver.component-name}") String component,
34-
TokenStore tokenStore, Configuration configuration) {
34+
@Value("${axon.axonserver.http-url}") String httpUrl,
35+
TokenStore tokenStore,
36+
Configuration configuration) {
3537
this.configuration = configuration;
36-
this.webClient = WebClient.create("http://localhost:8024");
38+
this.webClient = WebClient.create(httpUrl!=null?httpUrl:"http://localhost:8024");
3739
this.contextSupplier = () -> context;
3840
this.componentSupplier = () -> component;
3941
this.tokenStoreIdSupplier = () -> tokenStore.retrieveStorageIdentifier().get();

reset-handler/src/main/java/io/axoniq/service/ServerConnectorEventProcessorService.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public class ServerConnectorEventProcessorService implements EventProcessorServi
2222
private final Configuration configuration;
2323
private final AdminChannel adminChannel;
2424

25-
public ServerConnectorEventProcessorService(Configuration configuration, AdminChannel adminChannel) {
25+
public ServerConnectorEventProcessorService(Configuration configuration,
26+
AdminChannel adminChannel) {
2627
this.configuration = configuration;
2728
this.adminChannel = adminChannel;
2829
}

reset-handler/src/main/resources/application.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ axon:
22
axonserver:
33
context: "default"
44
component-name: "component"
5+
http-url: "http://127.0.0.1:8024"
56

reset-handler/src/test/java/io/axoniq/ResetServiceIntegrationTest.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.springframework.beans.factory.annotation.Autowired;
1313
import org.springframework.boot.test.context.SpringBootTest;
1414
import org.springframework.boot.test.mock.mockito.MockBean;
15+
import org.springframework.test.context.DynamicPropertyRegistry;
16+
import org.springframework.test.context.DynamicPropertySource;
1517
import org.testcontainers.containers.DockerComposeContainer;
1618
import org.testcontainers.containers.wait.strategy.Wait;
1719
import org.testcontainers.junit.jupiter.Container;
@@ -40,15 +42,27 @@ public class ResetServiceIntegrationTest {
4042

4143
private static final String EVENT_PROCESSOR_NAME="io.axoniq";
4244

45+
private static final int HTTP_PORT = 8024;
46+
private static final int GRPC_PORT = 8124;
47+
4348
@ClassRule
4449
@Container
4550
public static DockerComposeContainer environment =
4651
new DockerComposeContainer(new File("src/test/resources/compose-test.yml"))
47-
.withExposedService("axonserver", 8024, Wait.forListeningPort())
48-
.withExposedService("axonserver", 8124, Wait.forListeningPort())
52+
.withExposedService("axonserver", HTTP_PORT, Wait.forListeningPort())
53+
.withExposedService("axonserver", GRPC_PORT, Wait.forListeningPort())
4954
.waitingFor("axonserver", Wait.forLogMessage(".*Started AxonServer in .*",1));
5055

56+
@DynamicPropertySource
57+
public static void properties(DynamicPropertyRegistry registry) {
58+
59+
int grpcPort = environment.getServicePort("axonserver", GRPC_PORT);
60+
int httpPort = environment.getServicePort("axonserver", HTTP_PORT);
5161

62+
registry.add("axon.axonserver.servers", () -> "localhost:"+grpcPort);
63+
registry.add("axon.axonserver.http-url", () -> "http://localhost:"+httpPort);
64+
65+
}
5266
@BeforeEach
5367
void prepare(){
5468
createEvents();

reset-handler/src/test/java/io/axoniq/controller/ResetE2ETest.java

+15-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import org.springframework.boot.test.context.SpringBootTest;
99
import org.springframework.boot.test.mock.mockito.MockBean;
1010
import org.springframework.boot.web.server.LocalServerPort;
11+
import org.springframework.test.context.DynamicPropertyRegistry;
12+
import org.springframework.test.context.DynamicPropertySource;
1113
import org.springframework.test.web.reactive.server.WebTestClient;
1214
import org.testcontainers.containers.DockerComposeContainer;
1315
import org.testcontainers.containers.wait.strategy.Wait;
@@ -24,8 +26,8 @@
2426
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
2527
public class ResetE2ETest {
2628

27-
final static int PORT_A = 8024;
28-
final static int PORT_B = 8124;
29+
private static final int HTTP_PORT = 8024;
30+
private static final int GRPC_PORT = 8124;
2931

3032
@LocalServerPort
3133
private int port;
@@ -42,10 +44,19 @@ public class ResetE2ETest {
4244
@Container
4345
public static DockerComposeContainer environment =
4446
new DockerComposeContainer(new File("src/test/resources/compose-test.yml"))
45-
.withExposedService("axonserver", PORT_A, Wait.forListeningPort())
46-
.withExposedService("axonserver", PORT_B, Wait.forListeningPort())
47+
.withExposedService("axonserver", HTTP_PORT, Wait.forListeningPort())
48+
.withExposedService("axonserver", GRPC_PORT, Wait.forListeningPort())
4749
.waitingFor("axonserver", Wait.forLogMessage(".*Started AxonServer in .*",1));
50+
@DynamicPropertySource
51+
public static void properties(DynamicPropertyRegistry registry) {
4852

53+
int grpcPort = environment.getServicePort("axonserver", GRPC_PORT);
54+
int httpPort = environment.getServicePort("axonserver", HTTP_PORT);
55+
56+
registry.add("axon.axonserver.servers", () -> "localhost:"+grpcPort);
57+
registry.add("axon.axonserver.http-url", () -> "http://localhost:"+httpPort);
58+
59+
}
4960
@Test
5061
void testEventsAreCreated(){
5162
prepareIntegrationTest();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
axon:
2+
axonserver:
3+
context: "default"
4+
component-name: "component"
5+
http-url: "http://127.0.0.1:8024"
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
version: '3.3'
22
services:
33
axonserver:
4-
image: hackyaxonserver
5-
hostname: axonserver
6-
ports:
7-
- '8024:8024'
8-
- '8124:8124'
4+
image: 'axoniq/axonserver:4.6.0-dev'
5+
hostname: axonserver

0 commit comments

Comments
 (0)