Hello,
currently I am trying to start a new Spring Boot project with Axon 4.
I have some trouble to set everything up and get my project working by following the documentation.
Seems like the docs are not up to date (or maybe just missing a few things).
For example, the documentation says Axon is by default configured to work Axon Server.
When starting Axon Server and running my simple hello world application I just get the following error:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is AxonServerRemoteCommandHandlingException{message=An exception was thrown by the remote message handling component., errorCode='AXONIQ-4000', server='AxonHub'}] with root cause
org.axonframework.axonserver.connector.command.AxonServerRemoteCommandHandlingException: An exception was thrown by the remote message handling component.
at org.axonframework.axonserver.connector.command.AxonServerCommandBus$2.onNext(AxonServerCommandBus.java:139) ~[axon-server-connector-4.0.jar:4.0]
at org.axonframework.axonserver.connector.command.AxonServerCommandBus$2.onNext(AxonServerCommandBus.java:116) ~[axon-server-connector-4.0.jar:4.0]
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:407) ~[grpc-stub-1.13.1.jar:1.13.1]
at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33) ~[grpc-core-1.13.1.jar:1.13.1]
at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33) ~[grpc-core-1.13.1.jar:1.13.1]
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:519) ~[grpc-core-1.13.1.jar:1.13.1]
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.13.1.jar:1.13.1]
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) ~[grpc-core-1.13.1.jar:1.13.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_192]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_192]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_192]
In the next step, I tried to use the MongoDB event store. Unfortunately I wasn’t able to figure out how to configure Axon with MongoDB, since the documentation doesn’t give instructions on how to do this.
So, I am currently stuck.
Are there any working code examples for Axon 4 I could use as a reference?
Kind regards
Alexander
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@org.springframework.context.annotation.Configuration
public class AxonConfiguration {
private Logger logger = LoggerFactory.getLogger(getClass());
public AxonConfiguration() {
logger.info("Loading Axon Configuration");
}
@Bean(destroyMethod="shutdown")
public Configuration configuration(AxonServerConfiguration axonServerConfiguration, AxonServerConnectionManager axonServerConnectionManager) {
return DefaultConfigurer.defaultConfiguration()
.registerComponent(AxonServerConfiguration.class, c -> axonServerConfiguration)
.registerComponent(AxonServerConnectionManager.class, c -> {
c.onShutdown(axonServerConnectionManager::shutdown);
return axonServerConnectionManager;
})
.configureEventStore(this::buildEventStore)
.configureCommandBus(this::buildCommandBus)
.configureQueryBus(this::buildQueryBus)
.start();
}
@Bean
public AxonServerConfiguration axonServerConfiguration(Properties applicationConfig) {
return AxonServerConfiguration.builder()
.componentName(applicationConfig.getProperty("axon.axonserver.componentName", "PM"))
.servers(applicationConfig.getProperty("axon.axonserver.servers", "localhost"))
.token(applicationConfig.getProperty("axon.axonserver.token", ""))
.build();
}
@Bean(initMethod="getChannel")
public AxonServerConnectionManager axonServerConnectionManager(AxonServerConfiguration c) {
return new AxonServerConnectionManager(c);
}
public AxonServerEventStore buildEventStore(Configuration c) {
return AxonServerEventStore.builder()
.configuration(c.getComponent(AxonServerConfiguration.class))
.platformConnectionManager(c.getComponent(AxonServerConnectionManager.class))
.snapshotSerializer(c.serializer())
.eventSerializer(c.eventSerializer())
.upcasterChain(c.upcasterChain())
.build();
}
public AxonServerCommandBus buildCommandBus(Configuration c) {
AxonServerCommandBus commandBus = new AxonServerCommandBus(c.getComponent(AxonServerConnectionManager.class),
c.getComponent(AxonServerConfiguration.class),
SimpleCommandBus.builder().build(),
c.messageSerializer(),
c.getComponent(RoutingStrategy.class, AnnotationRoutingStrategy::new),
c.getComponent(CommandPriorityCalculator.class,
() -> new CommandPriorityCalculator() {}));
c.onShutdown(commandBus::disconnect);
return commandBus;
}
public QueryBus buildQueryBus(Configuration c) {
SimpleQueryBus localSegment = SimpleQueryBus.builder()
.transactionManager(c.getComponent(TransactionManager.class, NoTransactionManager::instance))
.errorHandler(c.getComponent(QueryInvocationErrorHandler.class, () -> LoggingQueryInvocationErrorHandler.builder().build()))
.queryUpdateEmitter(c.queryUpdateEmitter())
.messageMonitor(c.messageMonitor(QueryBus.class, "localQueryBus"))
.build();
AxonServerQueryBus queryBus = new AxonServerQueryBus(c.getComponent(AxonServerConnectionManager.class),
c.getComponent(AxonServerConfiguration.class),
c.queryUpdateEmitter(),
localSegment, c.messageSerializer(), c.serializer(), c.getComponent(QueryPriorityCalculator.class, () -> new QueryPriorityCalculator() {}));
c.onShutdown(queryBus::disconnect);
return queryBus;
}
}
--