当前位置: 首页 > news >正文

php做网站流程电商数据网站

php做网站流程,电商数据网站,南昌网站建设价位,软件开发自学网自定义线程池 Configuration public class MyThreadPool {//ThreadPoolTaskExecutor不会自动创建ThreadPoolExecutor,需要手动调initialize才会创建。如果Bean就不需手动,会自动InitializingBean的afterPropertiesSet来调initializeBean("myExecut…

自定义线程池

@Configuration
public class MyThreadPool {//ThreadPoolTaskExecutor不会自动创建ThreadPoolExecutor,需要手动调initialize才会创建。如果@Bean就不需手动,会自动InitializingBean的afterPropertiesSet来调initialize@Bean("myExecutor")public Executor createJobExecutor() {ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();// 线程池活跃的线程数executor.setCorePoolSize(20);// 设置线程队列最大线程数executor.setMaxPoolSize(40);// 设置等待队列大小executor.setQueueCapacity(200);// 线程池维护线程所允许的空闲时间executor.setKeepAliveSeconds(60);// 线程前缀名称executor.setThreadNamePrefix("myExecutor---: ");executor.initialize();return executor;}
}

实体类

public class StudentEvent extends ApplicationEvent{private String id;private String name;public StudentEvent(Object source, String id,String name) {super(source);this.id = id;this.name = name;}
}

事件发布

sevice层


public interface StudentService {void sendStudentEvent(String id, String name);
}

serviceImpl层

@Service
public class StudentServiceImpl implements StudentService {@AutowiredApplicationEventPublisher eventPublisher;@Override@Async("myExecutor")public void sendStudentEvent(String id, String name){StudentEvent studentEvent = new StudentEvent(this,id,name);eventPublisher.publishEvent(studentEvent);}
}

事件监听

@Component
public class MyStudentEventListener {@EventListener@Async("myExecutor")public void handleStudentEvent(StudentEvent studentEvent) {// 处理事件}
}

监听器的执行顺序
如果应用程序中有多个事件监听器,可以通过@Order 注解,指定它们的执行顺序。例如:

@Component
public class MyEventListener1 {@EventListener@Order(1)public void handleEvent(MyEvent event) {// 处理事件}
}@Component
public class MyEventListener2 {@EventListener@Order(2)public void handleEvent(MyEvent event) {// 处理事件}
}

监听器的条件
只想在特定条件下才执行事件监听器,可以使用 @ConditionalOnProperty 注解:

@Component
@ConditionalOnProperty(name = "myapp.event.listener.enabled", havingValue = "true")
public class MyEventListener {@EventListenerpublic void handleEvent(MyEvent event) {// 处理事件}
}

参考博客:https://blog.csdn.net/albert_xjf/article/details/131326148

http://www.tj-hxxt.cn/news/117824.html

相关文章:

  • 黄骅港开发区seo推广优化服务
  • 信阳制作网站ihanshi足球排名世界排名
  • 婚恋网站 没法做如何注册百度账号
  • 做仿牌网站被封搜索引擎优化的方式
  • 澄海网站建设微博今日热搜榜
  • 厦门网站建设服务找客户的软件有哪些
  • 杭州网站建设 seoseo技巧seo排名优化
  • 做网站备案不少天成都专门做网站的公司
  • 中央调查甘肃疫情最新消息谷歌seo搜索引擎下载
  • 赤峰做网站seo推广软件下载
  • 做亚马逊网站费用网站功能开发
  • 查询企业的网站有哪些网络推广运营外包公司
  • 怎么做外网网站监控免费建站的平台
  • 北京西站电话全网营销推广公司
  • 云梦建站怎么宣传自己的店铺
  • 辽宁省网站备案上海搜索优化推广
  • 兰州疫情到底有多么严重seo技术博客
  • 电信宽带做网站seo引擎优化工具
  • 博客网站模版竞猜世界杯
  • 网站开发后端是什么网站查询工具
  • 做盗版网站吗小程序推广方案
  • wordpress定制企业站黄桃图片友情链接
  • seo网站推广是什么百度收录怎么弄
  • 做网站的软件叫code中国北京出啥大事了
  • 重庆蒲公英网站建设公司怎么样怎么上百度推广产品
  • 使用他人api做网站seo免费诊断联系方式
  • 网络托管公司公司官网优化方案
  • 网站专题模板百度怎么联系客服
  • 如何做网站推广方法鸡西网站seo
  • 有没有代做模型的网站网页设计制作网站html代码大全