Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. class AR1{
  2. Integer id;
  3. DomainService ds;
  4.  
  5. //OPTION 1
  6. void createAr2RootOpt1(){
  7. AR2 ar2 = new AR2();
  8. ds.saveToRepo(ar2);
  9. }
  10.  
  11. //OPTION 2
  12. void createAr2RootOpt2(){
  13. publishEvent(new SholdCreateAR2Event()); //we don't need this event. Shoud it still be preserved in event store?
  14. }
  15. }
  16.  
  17. class AR2{
  18. Integer id;
  19. Integer ar1Id;
  20.  
  21. void handle(CreateAR2Command command){
  22. //init this AR with values and save
  23. publishEvent(AR2CreatedEvent()); //used for projections afterwards and saved inside AR2 event store
  24. }
  25. }
  26.  
  27. class Saga{
  28. void handle(SholdCreateAR2Event ev){
  29. emitCommand(new CreateAR2Command());
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement