作为研究用于项目的CQRS的一部分,我遇到了Axon框架,我想知道是否有人有任何真实的生活经验.为了清楚起见,我问的是框架,而不是CQRS作为一种架构模式.
我的项目已经使用了Spring和Spring Integration,非常适合Axon自己的要求,但在我花了很多时间之前,我想知道是否有人有一些亲身经验.特别是我对我可能存在的陷阱感兴趣,这些陷阱在文档中并不是很明显.
除了Axon Framework之外,还有其他任何用于CQRS和事件采购的Java框架吗?我特意找
我正在研究Spring Boot + Axon示例。遵循youtube 上的https://www.youtube.com/watch?v=lBKZOTe9QM4&list=PL4O1nDpoa5KTq5QKX9ueK-0QCJ-6Wm_ma链接并使用最新的依赖项。
如果我使用axon-core和axon-amqp版本到3.0-RC1那么它工作正常。但是我使用 3.4 版本,然后在启动时出现以下错误。任何快速帮助?
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call the method org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine.<init>(Lorg/axonframework/common/jpa/EntityManagerProvider;)V but it does not exist. Its class, org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine, is available from the following locations:
jar:file:/C:/Users/user/.m2/repository/org/axonframework/axon-core/3.4/axon-core-3.4.jar!/org/axonframework/eventsourcing/eventstore/jpa/JpaEventStorageEngine.class
It was loaded from the following location:
file:/C:/Users/user/.m2/repository/org/axonframework/axon-core/3.4/axon-core-3.4.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine
Run Code Online (Sandbox Code Playgroud)
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<!-- …Run Code Online (Sandbox Code Playgroud) 我们目前正在对CQRS和事件采购进行一些研究,并找到了两个主要框架来处理这两个问题:Axon Framework和Eventuate.两者都在不断发展,而现在在RBMH存储库中更积极地开发了Eventuate.
我是GIT克隆了两个示例项目,并得出结论,Eventuate看起来更轻一点,但我认为这是由于缺乏与Axon相比的功能.
我徒劳地试图找到这两个框架之间的比较,在Stackoverflow中我也找不到任何框架.有人有一些意见吗?
在我看来,CQRS(命令和查询责任隔离)方法可能适合在GAE上实现健壮且响应迅速的社交应用服务器,因为:
麻烦的是,我是一个生锈的Java程序员,几乎没有与这个选择相关的经验,我非常感谢任何使用过这两者的人的评论,或者至少使用其他人的经验进行调查.
我认为我的主要问题是:
是否可以在没有 Axon Server Enterprise 的情况下扩展 Axon 框架?我有兴趣使用 Axon 创建原型 CQRS 应用程序,但最终的可部署系统必须免收许可费。如果使用免费软件无法将 Axon Framework 扩展到六个节点,那么我可能应该寻找其他地方。
如果 Axon Framework 不是系统的好选择,您会推荐什么?围绕 Apache Pulsar 构建一些东西会是一个明智的选择吗?
我正在寻找比AxonFramework中的Saga更复杂的工作流程 - 我们目前正在使用它 - 我在Netflix Conductor中找到了一个.可悲的是,我在互联网上搜索了一个不错的例子,但无济于事.
我的问题是,在Netflix Conductor中,如何定义和创建Task或WorkflowTask,最重要的是,将微服务链接到它?这是来自github的Netflix指挥代码:
WorkflowDef def = new WorkflowDef();
def.setName("test");
WorkflowTask t0 = new WorkflowTask();
t0.setName("t0");
t0.setType(Type.SIMPLE);
t0.setTaskReferenceName("t0");
WorkflowTask t1 = new WorkflowTask();
t1.setName("t1");
t1.setType(Type.SIMPLE);
t1.setTaskReferenceName("t1");
def.getTasks().add(t0);
def.getTasks().add(t1);
Run Code Online (Sandbox Code Playgroud)
原谅我的困惑,因为我是Netflix Conductor的新手.
我目前正在使用Jhipster生成以下组件:
其他组件:
另外需要注意的是,自定义前端使用的是Jhipster angular 4代码,可以在vanilla Jhipster Api Gateway中找到.这包括customHttpProvider.
目前我能够使用此设置成功登录并在UAA上调用API,但是,当我尝试在产品上调用任何APIS时,我会获得401 Unauthorized,例如Post to Product1/api/zcd.
Consul中的服务都是可见的和绿色的,Gateway也有UAA和Product1作为注册和可用路线.
到目前为止,我发现当我对Product进行api调用时,似乎没有调用AuthInterceptor.我尝试手动将jwt令牌附加到方法,这解决了问题,但我不明白为什么customHttpProvider不被用于拦截请求和附加令牌.
如下所示,当我手动插入令牌时,我的ProductService工作正常,但这显然不是正确的方法.
@Injectable()
export class ProductService {
private options = new Headers();
constructor(private http: Http) {
this.options.append('Authorization', 'Bearer ' + 'token is inserted here');
}
priceProduct(productPriceRequest: productPriceRequest): Observable<IdResponse> {
return this.http.post('Product1/api/zcd', productPriceRequest, { headers: this.options })
.map(response => response.json());
}
}
Run Code Online (Sandbox Code Playgroud) 我使用 SpringBoot 和 Webflux 进行反应式编程。我想重复该服务,直到数据可用(除了 null 之外还返回一些内容)
\n我有一个将一些数据插入数据库的服务,并且有第二个服务消耗该数据。\n我想继续从第二个服务查询数据库,直到数据可用。下面的代码我试图使用 Project Reactor 来实现这一点:
\nMono<SubscriptionQueryResult<App, App>> subscriptionQuery = reactiveQueryGateway\n.subscriptionQuery(new FindAppByIdQuery(appId), ResponseTypes.instanceOf(App.class), ResponseTypes.instanceOf(App.class));\n\nsubscriptionQuery\n .filter(a -> Objects.nonNull(a.initialResult().block()))\n .repeatWhen(Repeat.onlyIf(repeatContext -> true)\n .exponentialBackoff(Duration.ofMillis(100), Duration.ofSeconds(100))\n .timeout(Duration.ofSeconds(30))).subscribe();\nRun Code Online (Sandbox Code Playgroud)\n在执行此操作时,我遇到以下异常:
\nreactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread parallel-1\nRun Code Online (Sandbox Code Playgroud)\n在浏览 webflux 文档时,我发现在 Reactor 线程中调用 block() 函数是不可能的。这样的尝试会导致上述错误:
\n为了克服这个问题,我尝试了以下方法:
\nsubscriptionQuery\n .flatMap(a -> a.initialResult())\n .filter(a -> Objects.nonNull(a))\n .repeatWhen(Repeat.onlyIf(repeatContext -> true)\n .exponentialBackoff(Duration.ofMillis(100), Duration.ofSeconds(100))\n .timeout(Duration.ofSeconds(30)))\n .subscribe();\nRun Code Online (Sandbox Code Playgroud)\n但它没有给我想要的结果,我想我错过了一些东西。任何人都可以建议实现这一目标的正确方法。
\n谢谢。
\n我一直在学习轴突和事件溯源,我想我终于理解了其中的一部分,并且在我的头脑中它是有意义的,但我想确保我对它的理解是正确的并且我没有犯任何错误。该代码有效,我也可以在 DOMAIN_EVENT_ENTRY 表中看到事件。
我将在下面发布我的代码(文档中的简单礼品卡示例)并解释我的思考过程。如果我没有正确理解它,请您帮助我以正确的方式理解该部分。
我没有包含命令/事件,因为它们非常简单,包含 id、金额字段
首先是我的代码:
测试运行器.java
package com.example.demoaxon;
import java.util.UUID;
import org.axonframework.commandhandling.gateway.CommandGateway;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@Component
@Slf4j
public class TestRunner implements CommandLineRunner {
private final CommandGateway commandGateway;
@Autowired
public TestRunner(CommandGateway commandGateway) {
this.commandGateway = commandGateway;
}
@Override
public void run(String... args) throws Exception {
log.info("send command");
String id = UUID.randomUUID().toString();
commandGateway.sendAndWait(new IssueCardCommand(id,100));
commandGateway.sendAndWait(new RedeemCardCommand(id,90));
}
}
Run Code Online (Sandbox Code Playgroud)
礼品卡.java
package com.example.demoaxon;
import org.axonframework.commandhandling.CommandHandler;
import org.axonframework.eventsourcing.EventSourcingHandler;
import org.axonframework.modelling.command.AggregateIdentifier;
import static org.axonframework.modelling.command.AggregateLifecycle.apply;
import org.axonframework.spring.stereotype.Aggregate;
import lombok.NoArgsConstructor;
import …Run Code Online (Sandbox Code Playgroud) axon ×10
cqrs ×5
java ×4
spring-boot ×2
amazon-swf ×1
angular ×1
lazy-loading ×1
netflix ×1
reactor ×1
repeat ×1