How to configure my application to connect to my axon server docker container?

Hello
how do I configure my spring boot application to connect to my AxonServer Docker container?

When I search for “how to connect to axon server with spring boot application” and the like I only get results for the configuration of the server.

I know there is the package org.axonframework.axonserver.connector and the classes

@ConfigurationProperties(prefix=“axon.axonserver”) public class AxonServerConfiguration extends Object

and

public class AxonServerConnectionManager extends Object

and
public class ServerConnectorConfigurerModule extends Object implements ConfigurerModule

Can I configure beans in my AxonConfiguration.java to tell the application the port etc. of the Server?

What values do I have to set in my application.properties or application.yml ?

Thanks!

Hello,
since I receive no answers it seems that there is a problem with my question. Could you please give me feedback at least, if so, such that I can ask better?

Thank you very much

No problem at all, but especially when it’s not office hours, it could take a while.

You can see most of the properties for configuring the axon Server connection here. For the servers this is axon.axonserver.servers which is a comma separated list of the servers, where the port will default to 8124.

Hello,

thanks for your answer!

The problem is not how to configure the server. There is more than enough material I think. But I do really think there is way too few information on how to connect to the server.

I have managed to do so now.

Here is the code:

package org.codetalker;

import io.axoniq.axonserver.connector.AxonServerConnection;
import org.axonframework.axonserver.connector.AxonServerConfiguration;
import org.axonframework.axonserver.connector.command.AxonServerCommandBus;
import org.axonframework.axonserver.connector.AxonServerConnectionManager;
import org.axonframework.config.Configuration;
import org.axonframework.config.DefaultConfigurer;
import org.axonframework.serialization.json.JacksonSerializer;


// import org.codetalker.config.AxonServerConnectionManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;



@SpringBootApplication
public class AxonServerTest {

    static private String servers = "localhost:8124";
    private String token = "";
    private String url = "";



    public static void main(String[] args) {
        AxonServerConfiguration configuration = AxonServerConfiguration.builder()
                .servers(servers)
                //.token(token)
                .componentName("AxonServerTest")
                .build();

        AxonServerConnectionManager connectionManager = AxonServerConnectionManager.builder()
                .axonServerConfiguration(configuration)
                .build();

        // start !
        connectionManager.start();

        AxonServerConnection axonServerConnection = connectionManager.getConnection();

        Configuration axonConfig = DefaultConfigurer.defaultConfiguration()
                .configureEventSerializer(c -> JacksonSerializer.builder().build())
                .registerComponent(org.axonframework.axonserver.connector.command.AxonServerCommandBus.class,
                        c -> AxonServerCommandBus.builder()
                                .axonServerConnectionManager(connectionManager)
                                .build())
                .buildConfiguration();
        axonConfig.start();

        connectionManager.shutdown();
        axonConfig.shutdown();
        SpringApplication.run(AxonServerTest.class, args);
    }
}

Too bad I received no replies. Please create an entry in the docs or in the dev blog or something because this can really be frustrating to search and always only get information on how to configurate the server, not on how to configure the application in order to connect to the server.

Would be great !

I’m not sure I properly understand the problem you have. If you are using Spring Boot with auto configuration, which you seem to be doing, you just optionally need to set some properties, and the rest will be auto wired for you.

The property and the link I shared was for the clients, not for configuring the server. I guess there might be more documentation on how to use Axon Server, when you don’t use Spring Boot through.

I am sorry that I have obviously misread your message. In what file do I put this list, could you tell me that?

Can you explain to a greenhorn what you mean by

The property and the link I shared was for the clients, not for configuring the server. I guess there might be more documentation on how to use Axon Server, when you don’t use Spring Boot through

Best wishes

Where should I put the values for the prefix axon.axonserver.servers? In application.properties, application.yml or whole another file? Or do you mean as argument to AxonConfiguration#setServer(String routingServers) ?

I’m not sure I properly understand the problem you have.
Well, sometimes the very basics are harder problems than many advanced topics as they are just premised and hence nowhere really described. I can imagine that basics like this are more or less self-evident to you. To me they are not yet.

It mostly depends on your setup where to put them. For example you could use a profile to use with docker, in which case they should be in a application-docker.properties or the Yaml variant. Up for personal preference.

It’s very much true there might be some things lacking, which might be obvious for experienced developers.

I was at your place a couple of months ago… So in order to setup the connection to your axon docker server, I have a question for you. Are you using Spring Boot? If you are, your server configuration will be done mostly in application.yml.