打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
5分钟快速体验Axon框架:构建CQRS架构和事件溯源的微服务应用

  在上一篇文章中,基于Axon框架,我们实现了一个具有CQRS(Command Query Responsibility Segregation,命令查询职责分离)和Event Sourcing(事件溯源)的订单微服务应用程序。

  本文,我们结合Axon Server运行该应用,体验事件溯源和事件存储(Event Store)功能特性。

  

专栏DDD领域驱动设计-货物运输系统作者:软件架构29.8币37人已购查看

  Axon Server有多种启动方式,比如Docker镜像、jar包等等。

  

  选择需要的版本运行即可:

  docker run -d --name axonserver -p 8024:8024 -p 8124:8124 axoniq/axonserver:4.2

  

  可以访问 http://localhost:8024/,查看Axon dashboard,验证Axon Server是否成功启动。

  

  启动我们已经编写好的微服务应用,示例项目如下所示:

  

  启动日志如下所示,会链接本地的Axon Server,然后会注册命令处理程序。

  2021-04-29 20:40:53.609 INFO 14373 --- [ main] i.a.a.c.impl.AxonServerManagedChannel : Requesting connection details from localhost:8124

  2021-04-29 20:40:53.828 INFO 14373 --- [ main] i.a.a.c.impl.AxonServerManagedChannel : Successfully connected to localhost:8124

  2021-04-29 20:40:53.837 INFO 14373 --- [ main] i.a.a.connector.impl.ControlChannelImpl : Connected instruction stream for context 'default'. Sending client identification

  2021-04-29 20:40:53.843 INFO 14373 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : CommandChannel for context 'default' connected, 0 command handlers registered

  2021-04-29 20:40:53.845 INFO 14373 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : Registered handler for command 'com.rickie.order.example.domain.commands.ConfirmOrderCommand' in context 'default'

  2021-04-29 20:40:53.848 INFO 14373 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : Registered handler for command 'com.rickie.order.example.domain.commands.ShipOrderCommand' in context 'default'

  2021-04-29 20:40:53.848 INFO 14373 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : Registered handler for command 'com.rickie.order.example.domain.commands.PlaceOrderCommand' in context 'default'

  2021-04-29 20:40:53.866 INFO 14373 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''

  2021-04-29 20:40:53.866 INFO 14373 --- [faces.events]-0] o.a.e.TrackingEventProcessor : Worker assigned to segment Segment[0/0] for processing

  2021-04-29 20:40:53.867 INFO 14373 --- [faces.events]-0] o.a.e.TrackingEventProcessor : Using current Thread for last segment worker: TrackingSegmentWorker{processor=com.rickie.order.example.interfaces.events, segment=Segment[0/0]}

  2021-04-29 20:40:53.868 INFO 14373 --- [faces.events]-0] o.a.e.TrackingEventProcessor : Fetched token: null for segment: Segment[0/0]

  2021-04-29 20:40:53.875 INFO 14373 --- [ main] c.r.o.example.AxonExampleApplication : Started AxonExampleApplication in 2.455 seconds (JVM running for 2.903)

  

专栏Axon框架快速入门和DDD项目实践作者:软件架构19.8币25人已购查看

  Axon Server控制台会显示有一个应用已经连接上来了,如图所示:

  

  客户端通过Postman发起POST请求,如图所示:

  

  可以在Axon Server控制台,查询Event Store,如图所示,显示该二手订单相关的事件记录。

  

  同时,在示例应用的控制台,也可以看到如下日志输出信息:

  

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Let Microservices Communicate Cleanly With CQRS and Event Sourcing
对CQRS的基础理解
软件各种系统架构图(二)
Andriod通话处理流程
JFinal+Jetty十行代码完成漂亮的RESTFul微服务框架
CQRS之旅——前言(翻译)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服