我们有一个项目需要长期的过程来检查付款是否已被遵守,如果是这样,记录必须提升到一个新的水平。由于要处理的记录数量巨大,我们决定使用 lmax 中断器。有什么选择?我们可以将 lmax 与 Spring Application Context 集成吗?
1 回答
将 bean 添加到 Context xml 并设置 lazy-load="false"
private final ExecutorService EXECUTOR = Executors.newFixedThreadPool(1); 私人 Disruptor 破坏者;私有环缓冲区环缓冲区;
@Autowired private PaymentCompletionHandler paymentCompletionHandler; 私有字符串 numberOfThreads;私有字符串 queueWarnLimit;
public void processTransaction(PaymentProcessBridge paymentProcessBridge) { 长序列 = ringBuffer.next(); // 抓取下一个序列 TransactionEvent transactionEvent = ringBuffer.get(sequence); transactionEvent.setPaymentProcessBridge(paymentProcessBridge); ringBuffer.publish(序列);}
public void init() {disruptor = new Disruptor(TransactionEvent.EVENT_FACTORY, 1024, EXECUTOR, ProducerType.SINGLE, new SleepingWaitStrategy());
disruptor.handleEventsWith(paymentCompletionHandler); ringBuffer = disruptor.start();
}