当前位置: 首页 > news >正文

国外免费建站网站搭建搜狗权重查询

国外免费建站网站搭建,搜狗权重查询,2021年4月重大新闻事件摘抄,网站设计需要需要用精心整理了最新的面试资料和简历模板#xff0c;有需要的可以自行获取 点击前往百度网盘获取 点击前往夸克网盘获取 简介 Axon Framework是一个用于构建CQRS#xff08;命令查询职责分离#xff09;和事件溯源#xff08;Event Sourcing#xff09;应用的框架#xff0…精心整理了最新的面试资料和简历模板有需要的可以自行获取 点击前往百度网盘获取 点击前往夸克网盘获取 简介 Axon Framework是一个用于构建CQRS命令查询职责分离和事件溯源Event Sourcing应用的框架而Spring Boot提供了快速开发能力。二者结合可高效实现高扩展性、可维护的分布式系统。 环境准备 JDK 17Spring Boot 3.2Axon Framework 4.9Maven/Gradle 步骤详解 1. 创建Spring Boot项目 使用start.spring.io生成基础项目选择 Spring WebLombok可选 2. 添加Axon依赖 !-- pom.xml -- dependencygroupIdorg.axonframework/groupIdartifactIdaxon-spring-boot-starter/artifactIdversion4.9.0/version /dependency3. 配置Axon可选 # application.yml axon:serializer:general: jacksoneventhandling:processors:default: tracking示例银行账户管理 1. 定义命令(Command) // 开户命令 public record CreateAccountCommand(String accountId, int initialBalance) {}// 存款命令 public record DepositMoneyCommand(String accountId, int amount) {}// 取款命令 public record WithdrawMoneyCommand(String accountId, int amount) {}2. 定义事件(Event) // 账户创建事件 public record AccountCreatedEvent(String accountId, int initialBalance) {}// 存款事件 public record MoneyDepositedEvent(String accountId, int amount) {}// 取款事件 public record MoneyWithdrawnEvent(String accountId, int amount) {}3. 创建聚合根(Aggregate) Aggregate Getter NoArgsConstructor public class BankAccountAggregate {AggregateIdentifierprivate String accountId;private int balance;CommandHandlerpublic BankAccountAggregate(CreateAccountCommand command) {apply(new AccountCreatedEvent(command.accountId(), command.initialBalance()));}CommandHandlerpublic void handle(DepositMoneyCommand command) {apply(new MoneyDepositedEvent(command.accountId(), command.amount()));}CommandHandlerpublic void handle(WithdrawMoneyCommand command) {if (balance command.amount()) {throw new InsufficientBalanceException();}apply(new MoneyWithdrawnEvent(command.accountId(), command.amount()));}EventSourcingHandlerpublic void on(AccountCreatedEvent event) {this.accountId event.accountId();this.balance event.initialBalance();}EventSourcingHandlerpublic void on(MoneyDepositedEvent event) {balance event.amount();}EventSourcingHandlerpublic void on(MoneyWithdrawnEvent event) {balance - event.amount();} }4. 创建Query处理 Service public class AccountQueryService {private final MapString, Integer accounts new ConcurrentHashMap();EventHandlerpublic void on(AccountCreatedEvent event) {accounts.put(event.accountId(), event.initialBalance());}EventHandlerpublic void on(MoneyDepositedEvent event) {accounts.computeIfPresent(event.accountId(), (k, v) - v event.amount());}EventHandlerpublic void on(MoneyWithdrawnEvent event) {accounts.computeIfPresent(event.accountId(), (k, v) - v - event.amount());}QueryHandlerpublic Integer handle(GetBalanceQuery query) {return accounts.get(query.accountId());} }5. 创建REST接口 RestController RequestMapping(/accounts) RequiredArgsConstructor public class AccountController {private final CommandGateway commandGateway;private final QueryGateway queryGateway;PostMappingpublic CompletableFutureString createAccount(RequestBody CreateAccountRequest request) {return commandGateway.send(new CreateAccountCommand(UUID.randomUUID().toString(),request.initialBalance()));}GetMapping(/{accountId}/balance)public CompletableFutureInteger getBalance(PathVariable String accountId) {return queryGateway.query(new GetBalanceQuery(accountId), Integer.class);} }运行与测试 启动Spring Boot应用使用curl测试 # 创建账户 curl -X POST -H Content-Type: application/json -d {initialBalance:1000} http://localhost:8080/accounts# 查询余额替换{accountId} curl http://localhost:8080/accounts/{accountId}/balance关键配置说明 序列化配置建议使用Jackson进行JSON序列化事件存储默认使用内存存储生产环境可配置JPA或JDBC分布式处理通过axon-distributed-command-bus实现命令总线扩展 扩展方向 添加JPA事件存储集成Spring Security进行权限控制配置Saga实现复杂事务使用Axon Server进行集群管理 通过本教程您已完成了一个基础的CQRS/ES系统实现。建议通过Axon Dashboard监控事件流并逐步添加更复杂的业务逻辑。
http://www.hkea.cn/news/14547375/

相关文章:

  • 无锡优化网站业务wordpress评论高亮
  • 竞争对手网站网站建设相关文章
  • 国内的网站空间潍坊外贸网站优化
  • 浙江建设厅证书查询官网seo关键词优化策略
  • 大学生做网站赚钱温州网络问政平台官网
  • 科技小发明小制作搜索引擎优化工作原理的先后顺序
  • 湖州网站建设哪家好搭建什么网站比较赚钱
  • 专业网站设计制作费用企业网站建设好的案例
  • 在重庆_那里可以做诚信网站认证阿里云服务器做网站需要备案
  • 网站企业型类做网站需要学编程吗
  • 新塘做网站合肥做网站优化
  • 网站建设评价标准无锡高端网站设计公司
  • 浙江省建设局城市平台网站wordpress apicloud
  • 专业的网站建站公司wordlink网站开发
  • 电商兼职网站开发小米商城网站建设
  • 物流网站建设实例江苏省建设考试网站
  • 做网站为什么赚钱wordpress影视站主题
  • 文具网站建设全网营销网站建设特点
  • 怎样学习做网站的编程化肥网站模板
  • 内江市住房和城乡建设局网站自微网站
  • 电脑端网站和手机网站区别用ps做衣服网站首页
  • 做国际网站花钱吗企业门户网站数据库设计
  • 新校区建设专题网站seo诊断书案例
  • 企业网站广告网站口碑营销
  • 诸城网站制作大部分网站是国内虚拟主机和国外虚拟主机
  • 镇江本地网站街景地图手机版下载
  • 平台网站建设设计深圳室内装修设计公司排名
  • 网站建设可用性的五个方面网站的安全建设或者解决方案
  • 网站制作注意事项dw网页制作视频
  • 建设工程 质量 协会网站西安云英网站建设