问题标签 [axon]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
rest - Axon - 如何在 CommandHandler 中检索新的实体版本号?
我目前正在编写一个具有微服务架构的分布式应用程序。
为此,我在轴突框架的帮助下应用了 CQRS 模式和事件溯源。因此数据最终是一致的。
写入端和读取端都可以通过 HTTP 访问;特别是 REST。
最初的问题:
更新/创建实体后,用户 [1] 应该能够看到结果。因为事件是异步处理的,所以客户端/UI 不知道实体何时真正更新(或创建)。因此,当客户端在发送更新请求之后但在事件处理之前获取数据时,将返回未更改的数据。因此,用户可能会认为应用程序已损坏和/或发送新请求。
解决方案尝试:
在寻找写后读问题的解决方案时,我偶然发现了这个博客条目。
建议在写响应中返回新的实体版本。然后,客户端可以使用预期的实体版本(作为预期标头)请求数据。如果实际版本等于或大于预期版本,则返回数据。否则返回一个带有Retry-After Header 的空响应。
问题:
当客户端向写入端发送 UpdateFoo 请求时,应用程序会通过 CommandGateway 发送相应的 UpdateFooCommand。该命令由发布 FooUpdatedEvent 的实体聚合处理。读取端接收此事件并更新其实体视图,该视图可通过读取端的 REST 接口访问。
这是由轴突框架控制的。@CommandHandler
处理程序分别用和注释@EventSourcingHandler
。
现在:如何在CommandHandler中获取受影响实体的新版本号,以便在更新响应中返回该版本号?
提前致谢
[1] 不仅是用户。也可以有非人类客户。
completable-future - Axon & CompletableFuture
当我尝试将 CompletableFuture 与 Axon 一起使用时,我遇到了问题。例如:
在 thenAcceptAsync - AggregateLifecycle.apply(event) 有意外行为。我的一些 @EventSourcingHandler 处理程序开始两次处理事件。有人知道如何解决吗?
我一直在阅读文档,我得到的一切都是:
在大多数情况下,DefaultUnitOfWork 将为您提供所需的功能。它期望处理发生在单个线程中。
所以,看来我应该以某种方式使用 CurrentUnitOfWork.get/set 方法,但仍然无法理解 Axon API。
domain-driven-design - 我如何使用 Axon 使用相同的第一个 InitAvailableQuantityCommand 重新初始化某些值?
假设我们有股票。此库存应保留产品 ID 和可用数量。该库存的用户可以频繁更新(InitAvailableQuantityCommand)可用数量。如果某些产品已售出,我们的系统将收到已售出事件(DecreaseAvailableQuantityCommand),并且已售出产品的可用数量应该减少。
它适用于下面的聚合,直到一件事,如果我再次尝试使用 InitAvailableQuantityCommand 重新初始化库存,该事件将被忽略并引发错误
已插入序列 [0] 处的聚合 [3333] 事件”
我试图达到的目标如下:
- InitAvailableQuantityCommand (productId = 1, 数量 = 10)
- DecreaseAvailableQuantityCommand(productId = 1,数量 = 1)
- DecreaseAvailableQuantityCommand(productId = 1,数量 = 1)
- 现在我们还有 8 种可用产品。
- 并且此时用户将使用 productId 1 的 20 个可用产品重新初始化库存。用户将发送一个新的 InitAvailableQuantityCommand (productId = 1, quantity = 20),此时它失败并且不起作用。
我错了什么?
谢谢。
spring - 公共 org.demo.ComplaintQueryObject org.demo.DemoComplaintsApplication$ComplaintAPI.find(java.lang.String) 映射
我正在开发Spring Boot + Axon + CQRS示例。在此示例中,在启动 main 方法时,出现以下错误。
看起来不能使用字符串代替 ID。我试图将字符串转换为 ID,但效果不佳。
你能指导我应该怎么做吗?这是我的整个源代码。
错误:
代码:
spring - org.axonframework.commandhandling.distributed.CommandDispatchException:命令不包含路由键
我正在开发Spring Boot + Axon + CQRS示例。在这个例子中,当击中
curl -H "Content-Type : application/json" -d '{"company" : "apple", "description" : "My Kep"}' http://localhost:8080
我已经启动了下面的服务器(axonserver-4.0.jar),我看不到修复错误的方法。如果您需要任何其他详细信息,请告诉我?
我收到以下错误:
pom.xml
主应用
卷曲命令
$ curl -H "Content-Type:application/json" -d '{"company" : "apple", "description" : "My Kep"}' localhost:8080 % Total % Received % Xferd Average Speed Time Time Time Current Dload 上传总花费的剩余速度 100 392 0 345 100 47 11129 1516 --:--:-- --:--:-- --:--:-- 12645{"timestamp":1540911397422,"status": 500,"error":"Internal Server Error","exception":"java.util.concurrent.CompletionException","message":"AxonServerCommandDispatchException{message=命令 [org.demo.DemoComplaintsApplication$FileComplaintCommand] 不包含路由键,errorCode='AXONIQ-4003', server='10296@841DTN2'}","path":“/”}
axon - 事件溯源和标准存储库可以混合使用吗?
在Axon中,我可以为每种聚合类型配置不同的存储库吗?我的一些聚合可能是事件源的,而如果不需要审计或恢复到较早的状态,则对其他人来说毫无意义。
在有关存储库和事件存储的文档中,它说要实现接口Repository<T>
,该接口绑定到特定类型的聚合。
这让我相信我可以实现一个Repository<Car>
,Repository<Garage>
等等,它可能是也可能不是事件源,用 Spring 注释它们,@Repository
我很高兴。是这样吗?
我知道存在类似的问题,但答案只是说明:
您只能使用单个存储库来加载聚合。
这并没有说明单个存储库是绑定到所有聚合还是绑定到一种聚合类型。
设置验证
作为一个附带问题,使用标准存储库而不是事件源存储库会缓解CQRS 中唯一性约束检查的问题吗?在存储聚合的状态时(与仅事件相反),我可以在底层持久性存储中定义唯一性约束。提交后,命令应该失败并且不应该分派任何事件。我对么?
java - 更正应用程序的类路径,使其包含一个兼容的 org.axonframework.eventsourcing.eventstore.jpa 版本
我正在研究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 版本,然后在启动时出现以下错误。有什么快速帮助吗?
pom.xml
DemoComplaintsApplication.java
java - 异常 Exception 与 SpringAMQPMessageSource.onMessage(Message, Channel) Axon 中的 throws 子句不兼容
我正在开发 Spring Boot + Axon Framework 开发演示在这里解释:https ://www.youtube.com/watch?v=Jp-rW-XOYzA&list=PLgGXSWYM2FpOa_FTla-x5Wd10dpmgrRC4&index=54 。在这个例子中,我只使用最新的依赖项,其他的东西我保持原样。
当我简单地运行代码时,我得到以下错误,并且这里已经有问题了。请指导我。
错误:-
DemoComplaintsStatsApplication.java
java - Axon Framework AMQP - Doesn't fetches the messages
I have developed Spring Boot + Axon (Bootiful CQRS with Axon)
code by taking reference from https://www.youtube.com/watch?v=Jp-rW-XOYzA&list=PLgGXSWYM2FpOa_FTla-x5Wd10dpmgrRC4&index=54
I've placed all by code here: https://github.com/JavaHelper/axon-tutorials/tree/master/axon-complaints-demo. The issue which I am facing is very weird issue.
Scenario-1:
If I start both the applications (one on 8080 and other on 8081)
and hit the below end-points, then nothing is appearing in the RabbitMQ queue and thus, nothing is coming when I hit the http://localhost:8081/
. It's blank.
CURL commands
Scenario-2:
If I start the demo-complaints
first and then hit above curl command then RabbitMQ shows the queues count 3. After that I start the demo-complaints-stats
successfully, then nothing shows up on the hit of http://localhost:8081/
Could anyone please guide what's wrong ?
Source code link already provided.