Lightweight event-driven framework
Better decoupling between components allows us to decouple our modules and domain boundaries in a domain-driven design (DDD) with a weak reference nature of events.
Originally used as an internal plugin for business decoupling and event distribution. In the ongoing optimization, interested can pay attention to it.
// init eventbus plugin
EventBus plugin = new EventBus();
//Asynchronous globally enabled, if not enabled by default, synchronous blocking processing
plugin.async(1024, 8);
// Scan the class that contains the @Listener annotation method AND Implement the ApplicationEventListener interface
//Set the scan jar package to include the imported third-party jar package, which is not scanned by default.
plugin.scanJar();
// Set the default scan packet life, the default full scan
plugin.scanPackage("com.github.edagarli.eventbus.listener");
// plugin start
plugin.start();
// send the first message
plugin.publish("123", new EventSource("test"));
// send the second message
plugin.publish("123", new EventSource("test111111"));
// One-to-many, one event, triggering multiple event processing
// Coexisting multiple events with the same tag. Providing priority processing. The smaller the value of priority, the greater the priority.
plugin.publish("test", new EventSource("123123"));
Awaitility.await().atMost(2, TimeUnit.MINUTES).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return eventBus.stop();
}
});
maven jar~
<dependency>
<groupId>com.github.edagarli</groupId>
<artifactId>azeroth-event</artifactId>
<version>1.0.0</version>
</dependency>
- Code refactoring, internal responsibilities are more subdivided, and convenient for extended point expansion
- Improvement of execution strategy
- Support rule triggering, support time rule triggering
- Support el dynamic expressions
- Final consistency (persistent processing such as placement, increase retry mechanism)
- Support concurrency, accelerate service processing efficiency, event publishing and asynchronous processing capability (disruptor)
- In-project service decoupling Observers and publishers do not interfere with each other
- Imitate the spring event-driven model. One-to-many release one event to trigger multiple event processing.
- Add multiple listener priority processing rights. In the case of asynchronous processing, the order of submission is guaranteed, and the order of execution is not guaranteed.
- Asynchronous queues support graceful downtime to ensure the reliability of memory channels
- Increase the threshold. In asynchronous mode, the ringbuffer exceeds the threshold. Automatically switch back to synchronous. Return to normal and switch to asynchronous mode again.