当前位置: 首页>>代码示例>>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;未经允许,请勿转载。