org.axonframework.config.Configuration Java Examples

The following examples show how to use org.axonframework.config.Configuration. 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 vote down vote up
@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: KafkaMessageSourceConfigurer.java    From extension-kafka with Apache License 2.0 5 votes vote down vote up
/**
 * Register a {@link Function} which uses the provided {@link Configuration} to build a {@link
 * SubscribableKafkaMessageSource}.
 *
 * @param subscribableKafkaMessageSource the {@link Function} which will build a {@link SubscribableKafkaMessageSource}
 */
public void registerSubscribableSource(
        Function<Configuration, SubscribableKafkaMessageSource<?, ?>> subscribableKafkaMessageSource) {
    subscribableKafkaMessageSources.add(new Component<>(
            () -> configuration, "subscribableKafkaMessageSource", subscribableKafkaMessageSource
    ));
}
 
Example #3
Source File: KafkaMessageSourceConfigurerTest.java    From extension-kafka with Apache License 2.0 5 votes vote down vote up
@Test
void testStartInitiatesRegisteredSubscribableSources(
        @Mock Configuration configuration,
        @Mock SubscribableKafkaMessageSource<?, ?> sourceOne,
        @Mock SubscribableKafkaMessageSource<?, ?> sourceTwo
) {
    testSubject.registerSubscribableSource(conf -> sourceOne);
    testSubject.registerSubscribableSource(conf -> sourceTwo);

    testSubject.initialize(configuration);
    testSubject.start();

    verify(sourceOne).start();
    verify(sourceTwo).start();
}
 
Example #4
Source File: KafkaMessageSourceConfigurerTest.java    From extension-kafka with Apache License 2.0 5 votes vote down vote up
@Test
void testShutdownClosesRegisteredSubscribableSources(
        @Mock Configuration configuration,
        @Mock SubscribableKafkaMessageSource<?, ?> sourceOne,
        @Mock SubscribableKafkaMessageSource<?, ?> sourceTwo
) {
    testSubject.registerSubscribableSource(conf -> sourceOne);
    testSubject.registerSubscribableSource(conf -> sourceTwo);

    testSubject.initialize(configuration);
    testSubject.shutdown();

    verify(sourceOne).close();
    verify(sourceTwo).close();
}
 
Example #5
Source File: BeanWrapper.java    From cdi with Apache License 2.0 5 votes vote down vote up
@Override
// Mark: Is this correct? Should I be doing something additional?
public void destroy(T instance, final CreationalContext<T> context) {
    if (clazz.equals(Configuration.class)) {
        logger.info("Shutting down Axon configuration.");
        ((Configuration) instance).shutdown();
    }

    instance = null;
    context.release();
}
 
Example #6
Source File: KafkaMessageSourceConfigurer.java    From extension-kafka with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Configuration config) {
    this.configuration = config;
}
 
Example #7
Source File: AxonCdiExtension.java    From cdi with Apache License 2.0 4 votes vote down vote up
private Configuration startConfiguration(Configurer configurer) {
    logger.info("Starting Axon configuration.");

    return configurer.start();
}
 
Example #8
Source File: LazyRetrievedModuleConfiguration.java    From cdi with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Configuration config) {
    getDelegate().initialize(config);
}
 
Example #9
Source File: AxonDefaultConfiguration.java    From cdi with Apache License 2.0 4 votes vote down vote up
@Produces
@ApplicationScoped
public CommandGateway commandGateway(Configuration configuration) {
    return configuration.commandGateway();
}