49 lines
1.3 KiB
Java
Raw Normal View History

package com.baeldung;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.baeldung.consumer.NotificationConsumer;
import reactor.Environment;
import reactor.bus.EventBus;
import static reactor.bus.selector.Selectors.$;
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application implements CommandLineRunner {
2016-12-28 08:19:55 +01:00
@Autowired
private EventBus eventBus;
@Autowired
private NotificationConsumer notificationConsumer;
@Bean
Environment env() {
return Environment.initializeIfEmpty().assignErrorJournal();
}
2016-12-28 08:19:55 +01:00
@Bean
EventBus createEventBus(Environment env) {
2016-12-28 08:19:55 +01:00
return EventBus.create(env, Environment.THREAD_POOL);
}
2016-12-28 08:19:55 +01:00
@Override
public void run(String... args) throws Exception {
eventBus.on($("notificationConsumer"), notificationConsumer);
}
2016-12-28 08:19:55 +01:00
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}