Disruptorの開発応用


         Disruptor。Disruptor , , , :BlockingQueue  , : --- --- 。
1 jar 
2  
`package vinux.web.openApi.controller;

import java.util.List; import java.util.Map;
import vinux.service.dao.VinuxCenterMemberSellerMapper; import vinux.service.entity.VinuxCenterMemberSeller;
public class Element {
private  VinuxCenterMemberSellerMapper sellerMapper;

private List mdcList ;

private Integer type;

private Map params;


public VinuxCenterMemberSellerMapper getSellerMapper() {
    return sellerMapper;
}

public void setSellerMapper(VinuxCenterMemberSellerMapper sellerMapper) {
    this.sellerMapper = sellerMapper;
}

public List getMdcList() {
    return mdcList;
}

public void setMdcList(List mdcList) {
    this.mdcList = mdcList;
}

public Integer getType() {
    return type;
}

public void setType(Integer type) {
    this.type = type;
}

public Map getParams() {
    return params;
}

public void setParams(Map params) {
    this.params = params;
}

} 3 package vinux.web.openApi.controller;
import java.util.List; import java.util.Map;
import vinux.service.dao.VinuxCenterMemberSellerMapper; import vinux.service.entity.VinuxCenterMemberSeller;
public class Element {
private  VinuxCenterMemberSellerMapper sellerMapper;

private List mdcList ;

private Integer type;

private Map params;


public VinuxCenterMemberSellerMapper getSellerMapper() {
    return sellerMapper;
}

public void setSellerMapper(VinuxCenterMemberSellerMapper sellerMapper) {
    this.sellerMapper = sellerMapper;
}

public List getMdcList() {
    return mdcList;
}

public void setMdcList(List mdcList) {
    this.mdcList = mdcList;
}

public Integer getType() {
    return type;
}

public void setType(Integer type) {
    this.type = type;
}

public Map getParams() {
    return params;
}

public void setParams(Map params) {
    this.params = params;
}

} 4 package vinux.web.openApi.controller;
import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map;
import vinux.service.dao.VinuxCenterMemberSellerMapper; import vinux.service.entity.VinuxCenterMemberSeller;
import com.lmax.disruptor.EventHandler; import com.lmax.disruptor.WorkHandler; /** * * updateProductWhereC_PRODUCT_COUNT\\ * * dayStartTime * * dayEndTime * */ public class Handler1 implements EventHandler, WorkHandler {
@Override
public void onEvent(Element event) throws Exception {
    try {
        SimpleDateFormat myFmt1=new SimpleDateFormat("yyyy-MM-dd"); 

        Map params = new HashMap(); 

        VinuxCenterMemberSellerMapper sellerMapper = event.getSellerMapper();

        List mdcList = event.getMdcList();

        for (VinuxCenterMemberSeller vinuxCenterMemberSeller : mdcList) {

            Date calculateDate = vinuxCenterMemberSeller.getCalculateDate();

            String format = myFmt1.format(calculateDate);
            params.put("dayStartTime", format+" 00:00:00");
            params.put("dayEndTime", format+" 23:59:59");
            params.put("id", vinuxCenterMemberSeller.getUserId());
            sellerMapper.updateProductWhereC_PRODUCT_COUNT(params);
        }
    } catch (Exception e) {

        e.printStackTrace();

    }


}   

@Override
public void onEvent(Element event, long arg1, boolean arg2) throws Exception {
    this.onEvent(event);  
}

} Service
5disruptor
Map