我们有一个项目需要长时间运行来检查付款是否已被遵守,如果是这样,记录必须提升到下一个级别。 由于他们有大量的记录要处理,我们决定使用lmax disruptor。 有什么选择?我们可以将lmax与Spring Application Context集成吗?
答案 0 :(得分:1)
将bean添加到Context xml并使lazy-load =" false"
私有final ExecutorService EXECUTOR = Executors.newFixedThreadPool(1); 私人破坏者干扰者; 私人RingBuffer ringBuffer;
@Autowired 私人PaymentCompletionHandler paymentCompletionHandler; private String numberOfThreads; private String queueWarnLimit;
public void processTransaction(PaymentProcessBridge paymentProcessBridge){ long sequence = ringBuffer.next(); //抓住下一个序列 TransactionEvent transactionEvent = ringBuffer.get(sequence); transactionEvent.setPaymentProcessBridge(paymentProcessBridge); ringBuffer.publish(序列); }
public void init(){ disruptor = new Disruptor( TransactionEvent.EVENT_FACTORY, 1024, 执行者, ProducerType.SINGLE, 新的SleepingWaitStrategy());
disruptor.handleEventsWith(paymentCompletionHandler);
ringBuffer = disruptor.start();
}