org.axonframework.eventhandling.EventBus Java Examples

The following examples show how to use org.axonframework.eventhandling.EventBus. 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: AxonCdiExtension.java    From cdi with Apache License 2.0 5 votes vote down vote up
/**
 * Scans for an event bus producer.
 *
 * @param processProducer process producer event.
 */
<T> void processEventBusProducer(
        @Observes final ProcessProducer<T, EventBus> processProducer) {
    // TODO Handle multiple producer definitions.

    logger.debug("Producer for event bus found: {}.", processProducer.getProducer());

    this.eventBusProducer = processProducer.getProducer();
}
 
Example #2
Source File: KafkaAutoConfigurationTest.java    From extension-kafka with Apache License 2.0 4 votes vote down vote up
@Bean
public EventBus eventBus() {
    return mock(EventBus.class);
}
 
Example #3
Source File: BankAccountCommandHandler.java    From AxonBank with Apache License 2.0 4 votes vote down vote up
public BankAccountCommandHandler(Repository<BankAccount> repository, EventBus eventBus) {
    this.repository = repository;
    this.eventBus = eventBus;
}
 
Example #4
Source File: ToDoItemRunner.java    From bearchoke with Apache License 2.0 4 votes vote down vote up
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 #5
Source File: ShoppingCartEventServlet.java    From cqrs-sample with MIT License 3 votes vote down vote up
@Override
    public void init(ServletConfig config) throws ServletException {
       super.init(config);

       ac = new ClassPathXmlApplicationContext("/axon-db2-configuration.xml");
       
       logger.debug("sono nella init della servlet");
       
       // we get the event bus from the application context
       EventBus eventBus = ac.getBean(EventBus.class);
//       eventBus.subscribe(eventListener);
	      
    }