References

1. The message system is event-driven

2. Spring stateMachine does state transition control

3. Persist to the db2 table in the listener

 

spring-boot-starter-redis for application-level caching

 

 

spring boot for integration

 

State Machine Engine Selection  

https://segmentfault.com/a/1190000009906317

 

 

 

Event-driven benefits:

1. To understand event-driven and programs, one needs to compare with non-event-driven programs. In fact, most modern programs are event-driven, such as multi-threaded programs, which are definitely event-driven . In the early days, there were many non-event-driven programs. When such programs needed to wait for a certain condition to be triggered, they would constantly check the condition until the condition was met, which was a waste of CPU time . The event-driven program has the opportunity to release the cpu to enter the sleep state (note that there is a chance, of course, the program can also decide not to release the cpu), when the event is triggered, it is awakened by the operating system, so that the cpu can be used more effectively.

An event-driven program must directly or indirectly have an event queue for storing events that cannot be processed in time .
4. The behavior of event-driven programs is completely controlled by externally input events. Therefore, there are a large number of such programs in event-driven systems, and events are used as the main communication method.
5. The event-driven program also has the biggest advantage that it can process the events in the queue in a certain order, and this order is determined by the triggering order of the events . This feature is often used to ensure certain processes. atomization.

 

 

 

When we send events to concrete views, we actually accomplish a fundamental change: a shift from the traditional streamlined program structure to the way events are triggered. This application has considerable flexibility, can deal with a variety of discrete, random events.

 

 

 

 Disruptors can be used in place of in-process queues.

 

http://ifeve.com/%e8%bd%af%e4%bb%b6%e6%9e%b6%e6%9e%84%e6%a8%a1%e5%bc%8f-%e7%ac%ac%e4%ba%8c%e7%ab%a0%e4%ba%8b%e4%bb%b6%e9%a9%b1%e5%8a%a8%e6%9e%b6%e6%9e%84%e4%b8%8a/

 

 

for (PicCrdInf picCrd : picCrdList) {
    if (!StringUtils.isBlank(picCrd.getAppNbr())) {
     String appNbr = picCrd.getAppNbr();
     String imgPhyId = getPhyIdByAppNbr(appNbr,crdAppImgAttrList);
     //没物理Id的直接退出
     if (com.cmbchina.cc.framework.utils.StringUtils.isEmptyString(imgPhyId)) {
//      log.error("3.1.x.物理ID为空,appNbr:" + appNbr + ", imgPhyId:"+imgPhyId);
      continue;
     }else{
      log.info("3.1.appNbr:" + appNbr + ", imgPhyId:"+imgPhyId);
      ImgIdInfDto i = new ImgIdInfDto(picCrd.getCrdOrdNbr(), imgPhyId);
      executor.execute(new DownPicTsk(insta, picCrd, i));
      cntTask++;   //Exit after all downloads are completed   }    }
     }


   

   while (true) {
// log.info("Number of threads in the thread pool: "+executor.getPoolSize()+", number of tasks waiting to be executed in the queue: "+
// executor.getQueue().size()+ ", the number of completed tasks: "+executor.getCompletedTaskCount());

    log.info(String.format("[monitor] [%d/%d] Active: %d, Completed: %d, Task: %d, isShutdown: %s, isTerminated: %s",
                     executor.getPoolSize(),
                     executor.getCorePoolSize(),
                     executor.getActiveCount(),
                     executor.getCompletedTaskCount(),
                     executor.getTaskCount(),
                     executor.isShutdown(),
                     executor.isTerminated()));
    
    log.info("crdAppImgAttrList数目:"+crdAppImgAttrList.size()+",cntTask:"+cntTask);
    if (crdAppImgAttrList.size() == executor.getCompletedTaskCount()) {
     break;
    }else{
     Thread.sleep(2000);
    }
   }

 

 

ThreadPoolExecutor executor = new ThreadPoolExecutor(coreSize, maxPoolSize, keepAliveSeconds, TimeUnit.MILLISECONDS,
   new ArrayBlockingQueue<Runnable>(queueCapacity),Executors.defaultThreadFactory(),new ThreadPoolExecutor.CallerRunsPolicy()){
             @Override
             protected void terminated() {
                 log.info("线程池已处于TERMINATED状态");
             }
  };

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326117792&siteId=291194637