ValueObject Bet { String betOfferId String customerId Double amount Repository BetRepository { save; } } Service BettingEngine { inject @BetRepository placeBet(@Bet bet); } <p class="indent">
DomainEvent BetPlaced { - Bet bet } Service BettingPublisher { publishEvent(@BetPlaced betEvent) publish to jms:topic:bet; //发送消息 } <p class="indent">
Module customer { Consumer BettingConsumer { inject @CustomerStatisticsRepository subscribe to jms:topic:bet //注意接受JMS消息 } Service BettingQueryService { getHighBetters => CustomerStatisticsRepository.findHighAverageCustomers; } Entity CustomerStatistics { gap String customerId key int numberOfBets double averageAmount index Repository CustomerStatisticsRepository { findByKey; save; List<@CustomerStatistics> findHighAverageCustomers(double limit); protected findByCondition; } } } <p class="indent">
本案例源代码下载源码是以MongoDB为持久层,使用ActiveMQ 作为事件中线。
[该贴被admin于2010-09-13 09:04修改过]
CQRS模式要好于MVC模型
[该贴被banq于2010-09-10 10:26修改过]
Repository BetRepository { save; } <p class="indent">
[该贴被cleanearth于2010-09-10 12:38修改过]