當前位置: 首頁>>代碼示例>>Java>>正文


Java Disruptor.setDefaultExceptionHandler方法代碼示例

本文整理匯總了Java中com.lmax.disruptor.dsl.Disruptor.setDefaultExceptionHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java Disruptor.setDefaultExceptionHandler方法的具體用法?Java Disruptor.setDefaultExceptionHandler怎麽用?Java Disruptor.setDefaultExceptionHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.lmax.disruptor.dsl.Disruptor的用法示例。


在下文中一共展示了Disruptor.setDefaultExceptionHandler方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lessonStdCountUpdateCmdProcessor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
@Bean
public ItemAmountUpdateCommandProcessor lessonStdCountUpdateCmdProcessor() {

  CommandEventProducer<ItemAmountUpdateCommand>[] commandEventProducerList = new CommandEventProducer[conf.getNum()];

  for (int i = 0; i < conf.getNum(); i++) {

    ItemAmountUpdateCommandBuffer cmdBuffer = new ItemAmountUpdateCommandBuffer(conf.getSqlBufferSize());
    ItemAmountUpdateCommandExecutor cmdExecutor = new ItemAmountUpdateCommandExecutor(jdbcTemplate);

    Disruptor<CommandEvent<ItemAmountUpdateCommand>> disruptor = new Disruptor<>(
        new CommandEventFactory(),
        conf.getQueueSize(),
        Executors.defaultThreadFactory());

    disruptor
        .handleEventsWith(new CommandEventDbHandler(cmdBuffer, cmdExecutor))
        .then(new CommandEventGcHandler())
    ;
    // disruptor 的異常處理是這樣的,
    // 不論這種形式 A->B, 還是這種形式 A,B->C,D, 隻有拋出異常的那個handler會中斷執行
    disruptor.setDefaultExceptionHandler(new CommandEventExceptionHandler());

    commandEventProducerList[i] = new CommandEventProducer<>(disruptor.getRingBuffer());

    BeanRegisterUtils.registerSingleton(
        applicationContext,
        "CommandEvent<ItemAmountUpdateCommand>_DisruptorLifeCycleContainer_" + i,
        new DisruptorLifeCycleContainer("CommandEvent<ItemAmountUpdateCommand>_Disruptor_" + i, disruptor,
            StartupOrderConstants.DISRUPTOR_ITEM_UPDATE));

  }

  ItemAmountUpdateCommandProcessor cmdProcessor = new ItemAmountUpdateCommandProcessor(commandEventProducerList);

  commandDispatcher.registerCommandProcessor(cmdProcessor);

  return cmdProcessor;

}
 
開發者ID:bighector,項目名稱:-artemis-disruptor-miaosha,代碼行數:41,代碼來源:ItemAmountUpdateProcessorConfiguration.java

示例2: courseTakeInsertCmdProcessor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
@Bean
public OrderInsertCommandProcessor courseTakeInsertCmdProcessor() {

  LOGGER.info("Configure OrderInsertCommandProcessor");

  CommandEventProducer<OrderInsertCommand>[] commandEventProducerList = new CommandEventProducer[conf.getNum()];

  for (int i = 0; i < conf.getNum(); i++) {

    OrderInsertCommandBuffer cmdBuffer = new OrderInsertCommandBuffer(conf.getSqlBufferSize());
    OrderInsertCommandExecutor cmdExecutor = new OrderInsertCommandExecutor(jdbcTemplate);

    Disruptor<CommandEvent<OrderInsertCommand>> disruptor = new Disruptor<>(
        new CommandEventFactory(),
        conf.getQueueSize(),
        Executors.defaultThreadFactory());

    disruptor
        .handleEventsWith(new CommandEventDbHandler(cmdBuffer, cmdExecutor))
        .then(new CommandEventGcHandler())
    ;
    // disruptor 的異常處理是這樣的,
    // 不論這種形式 A->B, 還是這種形式 A,B->C,D, 隻有拋出異常的那個handler會中斷執行
    disruptor.setDefaultExceptionHandler(new CommandEventExceptionHandler());

    commandEventProducerList[i] = new CommandEventProducer<>(disruptor.getRingBuffer());

    BeanRegisterUtils.registerSingleton(
        applicationContext,
        "CommandEvent<OrderInsertCommand>_DisruptorLifeCycleContainer_" + i,
        new DisruptorLifeCycleContainer("CommandEvent<OrderInsertCommand>_Disruptor_" + i, disruptor,
            StartupOrderConstants.DISRUPTOR_ORDER_INSERT));

  }

  OrderInsertCommandProcessor cmdProcessor = new OrderInsertCommandProcessor(commandEventProducerList);

  commandDispatcher.registerCommandProcessor(cmdProcessor);

  return cmdProcessor;

}
 
開發者ID:bighector,項目名稱:-artemis-disruptor-miaosha,代碼行數:43,代碼來源:OrderInsertProcessorConfiguration.java


注:本文中的com.lmax.disruptor.dsl.Disruptor.setDefaultExceptionHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。