A Disruptor + Redis Queue
draw inspiration from https://github.com/zhangkaitao
spring-boot application support
maven dependency import
<dependency>
<groupId>io.yec</groupId>
<artifactId>fresno-spring-boot-starter</artifactId>
<version>${fresno.version}</version>
</dependency>
define EventHandler
@EventHandler
public class OrderEventListener implements EventListener<Order> {
@Resource
private FooService fooService;
@Override
public void onEvent(EventQueue<Order> eventQueue, Event<Order> event) {
try {
fooService.getOrder(event.getObj());
} catch (Exception e) {
e.printStackTrace();
}
}
}
reference EventQueue
@Service
public class FooServiceImpl implements FooService {
@EventQueueReference(belongTo = OrderEventListener.class)
private EventQueue<Order> orderEventQueue;
@Override
public void enQueueOrder(Order order) {
log.info("enQueueOrder :: {}", order);
orderEventQueue.enqueueToBack(order);
}
}