org.axonframework.commandhandling.CommandBus Java Examples
The following examples show how to use
org.axonframework.commandhandling.CommandBus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AxonManualApplication.java From spring-5-examples with MIT License | 6 votes |
@SneakyThrows public static void disabledMain(String[] args) { final Configuration configuration = DefaultConfigurer.defaultConfiguration() .configureAggregate(Entrance.class) .configureAggregate(Guest.class) .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine()) .configureCommandBus(c -> new AsynchronousCommandBus()) .buildConfiguration(); configuration.start(); final CommandBus commandBus = configuration.commandBus(); commandBus.dispatch(asCommandMessage(new RegisterEntranceCommand("main"))); commandBus.dispatch(asCommandMessage(new UnlockEntranceCommand("main"))); commandBus.dispatch(asCommandMessage(new UnregisterEntranceCommand("main")) ); TimeUnit.SECONDS.sleep(1L); }
Example #2
Source File: AxonCdiExtension.java From cdi with Apache License 2.0 | 5 votes |
/** * Scans for a command bus producer. * * @param processProducer process producer event. */ <T> void processCommandBusProducer( @Observes final ProcessProducer<T, CommandBus> processProducer) { // TODO Handle multiple producer definitions. logger.debug("Producer for command bus found: {}.", processProducer.getProducer()); this.commandBusProducer = processProducer.getProducer(); }
Example #3
Source File: UserDBInit.java From bearchoke with Apache License 2.0 | 5 votes |
@Autowired public UserDBInit(CommandBus commandBus, UserRepository userRepository, MongoTemplate mongoTemplate) { this.commandBus = commandBus; this.userRepository = userRepository; this.mongoTemplate = mongoTemplate; }
Example #4
Source File: RoleDBInit.java From bearchoke with Apache License 2.0 | 5 votes |
@Autowired public RoleDBInit(CommandBus commandBus, MongoTemplate mongoTemplate, RoleRepository roleRepository) { this.commandBus = commandBus; this.mongoTemplate = mongoTemplate; this.roleRepository = roleRepository; }
Example #5
Source File: FacebookController.java From bearchoke with Apache License 2.0 | 5 votes |
@Autowired public FacebookController(CommandBus commandBus, UserDetailsService userDetailsService, ApiAuthenticationSuccessHandler apiAuthenticationSuccessHandler) { this.commandBus = commandBus; this.userDetailsService = userDetailsService; this.apiAuthenticationSuccessHandler = apiAuthenticationSuccessHandler; }
Example #6
Source File: BankTransferManagementSaga.java From AxonBank with Apache License 2.0 | 4 votes |
@Autowired public void setCommandBus(CommandBus commandBus) { this.commandBus = commandBus; }
Example #7
Source File: UserAuthenticationProvider.java From bearchoke with Apache License 2.0 | 4 votes |
public UserAuthenticationProvider(CommandBus commandBus) { this.commandBus = commandBus; }
Example #8
Source File: ToDoItemRunner.java From bearchoke with Apache License 2.0 | 4 votes |
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( SchedulerConfig.class, RabbitMQLocalConfig.class, AxonCQRSConfig.class, ToDoConfig.class ); try { // let's start with the Command Bus // CommandBus commandBus = new SimpleCommandBus(); CommandBus commandBus = ctx.getBean(CommandBus.class); // the CommandGateway provides a friendlier API // CommandGateway commandGateway = new DefaultCommandGateway(commandBus); CommandGateway commandGateway = ctx.getBean(CommandGateway.class); // we'll store Events on the FileSystem, in the "events/" folder // EventStore eventStore = new FileSystemEventStore(new SimpleEventFileResolver(new File("./events"))); // EventStore eventStore = ctx.getBean(EventStore.class); // a Simple Event Bus will do // EventBus eventBus = new SimpleEventBus(); EventBus eventBus = ctx.getBean(EventBus.class); // we need to configure the repository // EventSourcingRepository repository = new EventSourcingRepository(ToDoItem.class, eventStore); // repository.setEventBus(eventBus); EventSourcingRepository repository = ctx.getBean("toDoItemRepository", EventSourcingRepository.class); // Axon needs to know that our ToDoItem Aggregate can handle commands // AggregateAnnotationCommandHandler.subscribe(ToDoItem.class, repository, commandBus); // AnnotationEventListenerAdapter.subscribe(new ToDoEventHandler(), eventBus); // and let's send some Commands on the CommandBus. final ToDoIdentifier id = new ToDoIdentifier(); commandGateway.send(new CreateToDoItemCommand(id, "Need to do this", "user")); commandGateway.send(new MarkToDoItemAsCompleteCommand(id, "user")); } finally { ctx.destroy(); } }
Example #9
Source File: ToDoController.java From bearchoke with Apache License 2.0 | 4 votes |
@Autowired public ToDoController(CommandBus commandBus) { this.commandBus = commandBus; }
Example #10
Source File: UserController.java From bearchoke with Apache License 2.0 | 4 votes |
@Autowired public UserController(CommandBus commandBus, UserRepository userRepository) { this.commandBus = commandBus; this.userRepository = userRepository; }
Example #11
Source File: MockServerConfig.java From bearchoke with Apache License 2.0 | 4 votes |
@Bean(name = "commandBus") public CommandBus commandBus() { return mock(CommandBus.class); }
Example #12
Source File: AppConfig.java From ESarch with Apache License 2.0 | 2 votes |
/** * We have chosen to take this <i>optional</i> step in order to benefit from automatic logging of every command * message being published on to the {@link CommandBus}. These are `INFO` level statements of every action. * We have qualified the given CommandBus parameter with 'localSegment' as we are using a * {@link DistributedCommandBus} and we want to associate this {@link LoggingInterceptor} with the local CommandBus * node. * * @param commandBus the {@link CommandBus} auto configured for this application */ @Autowired public void configure(@Qualifier("localSegment") CommandBus commandBus) { commandBus.registerHandlerInterceptor(new LoggingInterceptor<>()); }