Java Code Examples for org.springframework.context.event.SimpleApplicationEventMulticaster#setTaskExecutor()

The following examples show how to use org.springframework.context.event.SimpleApplicationEventMulticaster#setTaskExecutor() . 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: AppConfig.java    From flow-platform-x with Apache License 2.0 6 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster() {

        @Override
        public void multicastEvent(ApplicationEvent event, ResolvableType eventType) {
            if (event instanceof SyncEvent) {
                ResolvableType type = (eventType != null ? eventType : ResolvableType.forInstance(event));
                for (final ApplicationListener<?> listener : getApplicationListeners(event, type)) {
                    invokeListener(listener, event);
                }
                return;
            }

            super.multicastEvent(event, eventType);
        }
    };

    SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor("s-event-");
    multicaster.setTaskExecutor(executor);
    return multicaster;
}
 
Example 2
Source File: ButlerConfig.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster eventMulticaster =
        new SimpleApplicationEventMulticaster();
    eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return eventMulticaster;
}
 
Example 3
Source File: NotificationEventListenerTest.java    From stream-registry with Apache License 2.0 5 votes vote down vote up
@Bean
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
  SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
  eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());

  return eventMulticaster;
}
 
Example 4
Source File: NotificationEventListenerKafkaIntegrationTest.java    From stream-registry with Apache License 2.0 5 votes vote down vote up
@Bean
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
  SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
  eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());

  return eventMulticaster;
}
 
Example 5
Source File: NotificationEventBusConfig.java    From stream-registry with Apache License 2.0 5 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
  SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
  eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());

  return eventMulticaster;
}
 
Example 6
Source File: InputAdaptersConfiguration.java    From ddd-with-spring with Apache License 2.0 5 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
	SimpleApplicationEventMulticaster eventMulticaster
			= new SimpleApplicationEventMulticaster();

	eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
	return eventMulticaster;
}
 
Example 7
Source File: Application.java    From daming with Apache License 2.0 5 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster eventMulticaster
            = new SimpleApplicationEventMulticaster();

    eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return eventMulticaster;
}
 
Example 8
Source File: AsynchronousSpringEventsConfig.java    From wetech-admin with MIT License 5 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster eventMulticaster
            = new SimpleApplicationEventMulticaster();
    eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return eventMulticaster;
}
 
Example 9
Source File: AsynchronousSpringEventsConfiguration.java    From integration-patterns with MIT License 5 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    final SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();

    // FIXME use fixed size thread pool
    eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return eventMulticaster;
}
 
Example 10
Source File: MetacatApplicationEventMulticaster.java    From metacat with Apache License 2.0 5 votes vote down vote up
private ApplicationEventMulticaster createApplicationEventMultiCaster(final String name) {
    final SimpleApplicationEventMulticaster result = new SimpleApplicationEventMulticaster();
    final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(metacatProperties.getEvent().getBus().getExecutor().getThread().getCount());
    executor.initialize();
    RegistryUtil.registerThreadPool(registry, "metacat.event.pool." + name,
        executor.getThreadPoolExecutor());
    result.setTaskExecutor(executor);
    return result;
}
 
Example 11
Source File: TestConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
SimpleApplicationEventMulticaster applicationEventMulticaster(final ApplicationEventFilter applicationEventFilter) {
    final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new FilterEnabledApplicationEventPublisher(
            applicationEventFilter);
    simpleApplicationEventMulticaster.setTaskExecutor(asyncExecutor());
    return simpleApplicationEventMulticaster;
}
 
Example 12
Source File: EventPublisherAutoConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Server internal event publisher that allows parallel event processing if
 * the event listener is marked as so.
 *
 * @return publisher bean
 */
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
ApplicationEventMulticaster applicationEventMulticaster(@Qualifier("asyncExecutor") final Executor executor,
        final TenantAware tenantAware) {
    final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new TenantAwareApplicationEventPublisher(
            tenantAware, applicationEventFilter());
    simpleApplicationEventMulticaster.setTaskExecutor(executor);
    return simpleApplicationEventMulticaster;
}
 
Example 13
Source File: AsynchronousSpringEventConfiguration.java    From data-prep with Apache License 2.0 5 votes vote down vote up
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();

    eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return eventMulticaster;
}
 
Example 14
Source File: EventsAutoConfiguration.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * A multicast event publisher to replace the default one used by Spring via the ApplicationContext.
 *
 * @param syncTaskExecutor  The synchronous task executor to use
 * @param asyncTaskExecutor The asynchronous task executor to use
 * @return The application event multicaster to use
 */
@Bean
@ConditionalOnMissingBean(GenieEventBus.class)
public GenieEventBusImpl applicationEventMulticaster(
    @Qualifier("genieSyncTaskExecutor") final SyncTaskExecutor syncTaskExecutor,
    @Qualifier("genieAsyncTaskExecutor") final AsyncTaskExecutor asyncTaskExecutor
) {
    final SimpleApplicationEventMulticaster syncMulticaster = new SimpleApplicationEventMulticaster();
    syncMulticaster.setTaskExecutor(syncTaskExecutor);

    final SimpleApplicationEventMulticaster asyncMulticaster = new SimpleApplicationEventMulticaster();
    asyncMulticaster.setTaskExecutor(asyncTaskExecutor);
    return new GenieEventBusImpl(syncMulticaster, asyncMulticaster);
}