2

我目前的目标是使用 Spring Boot 启动器构建一个项目,以使用 Jgroups 测试分布式命令。

我在运行时收到此消息:收到未知消息:org.axonframework.jgroups.commandhandling.JoinMessage

它来自 org.axonframework.jgroups.commandhandling.JGroupsConnector

@Override
public void receive(Message msg) {
    Object message = msg.getObject();
    if (message instanceof JoinMessage) {
        processJoinMessage(msg, (JoinMessage) message);
    } else if (message instanceof JGroupsDispatchMessage) {
        processDispatchMessage(msg, (JGroupsDispatchMessage) message);
    } else if (message instanceof JGroupsReplyMessage) {
        processReplyMessage((JGroupsReplyMessage) message);
    } else {
        logger.warn("Received unknown message: " + message.getClass().getName());
    }
}

当前 POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>spring-axon-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>spring-axon-example</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring-boot-starter</artifactId>
        <version>3.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring-boot-starter-jgroups</artifactId>
        <version>3.2.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
</project>

控制台输出

2018-07-20 08:38:01.652  WARN 9439 --- [localhost-29107] o.a.j.commandhandling.JGroupsConnector   : Received unknown message: org.axonframework.jgroups.commandhandling.JGroupsDispatchMessage

应用

package com.example.demo;

import org.axonframework.eventsourcing.eventstore.EventStorageEngine;
import org.axonframework.eventsourcing.eventstore.inmemory.InMemoryEventStorageEngine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class SpringAxonExampleApplication {

public static void main(String[] args) {
    SpringApplication.run(SpringAxonExampleApplication.class, args);
}

@Bean
public EventStorageEngine eventStoreEngine() {
    return new InMemoryEventStorageEngine();
}
}

应用程序.properties

spring.datasource.url=jdbc:mariadb://localhost/axoncqrs
spring.datasource.username=1
spring.datasource.password=1
server.port=8033
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.globally_quoted_identifiers=true

java.net.preferIPv4Stack=true
axon.distributed.enabled=true
axon.distributed.jgroups.bind-addr=GLOBAL
axon.distributed.jgroups.bind-port=7800
axon.distributed.jgroups.cluster-name=Axon
axon.distributed.jgroups.configuration-file=default_tcp_gossip.xml
axon.distributed.jgroups.gossip.hosts=localhost[12001]
axon.distributed.jgroups.gossip.auto-start=true

这就像同时有两个类定义。感觉很迷茫,有什么线索吗?

问候

弗朗西斯科

4

1 回答 1

0

我希望从你的pom.xml和财产中我可能会有些不对劲。但是,我唯一能猜到的是,您的类路径/Maven 存储库中可能有两个不同版本的 Axon 框架。您是否尝试过删除/清除所有依赖的现有库并再次运行应用程序?


更新

游戏有点晚了,但我注意到您正在使用spring-boot-devtools依赖项。请注意,目前 Axon 框架不能很好地与 devtools 配合使用,例如在本期中所标记。您是否尝试过消除依赖以解决手头的问题?

于 2018-07-31T12:42:23.903 回答