Authored by wangnan

publisher上报的代码整理

... ... @@ -68,6 +68,4 @@ public class EsWordDefMqListener extends AbstractMqListener implements ChannelAw
esWordDefService.delete(Integer.valueOf(id));
logger.info("[func=deleteData][key={}][id={}][cost={}ms]", key, id, (System.currentTimeMillis() - begin));
}
}
... ...
... ... @@ -4,12 +4,9 @@ import com.rabbitmq.client.Channel;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.increment.otherIndex.RobotQuestionMqListener;
import com.yoho.search.consumer.service.logic.SalesCategoryLogicService;
import com.yoho.search.dal.model.SalesCategory;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -20,16 +17,20 @@ import java.util.Map;
@Component
public class SalesCategoryMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(RobotQuestionMqListener.class);
@Autowired
private SalesCategoryLogicService salesCategoryLogicService;
@Override
public String getIndexName() {
return null;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(buildSearchEvent(EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE,e));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SALESCATEGORYMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -54,10 +55,4 @@ public class SalesCategoryMqListener extends AbstractMqListener implements Chann
salesCategoryLogicService.deleteById(Integer.valueOf(id));
salesCategoryLogicService.doReload();
}
@Override
public String getIndexName() {
return null;
}
}
... ...
... ... @@ -32,6 +32,11 @@ public class ScoreRuleMqListener extends AbstractMqListener implements ChannelAw
private ScoreRuleLogicService scoreRuleLogicService;
@Override
public String getIndexName() {
return null;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
... ... @@ -72,10 +77,5 @@ public class ScoreRuleMqListener extends AbstractMqListener implements ChannelAw
logger.info("[func=deleteData][id={}][cost={}ms]", id, System.currentTimeMillis() - begin);
}
}
@Override
public String getIndexName() {
return null;
}
}
... ...
... ... @@ -22,13 +22,15 @@ import java.util.Map;
*/
@Component
public class ShopsBrandsMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(ShopsBrandsMqListener.class);
@Autowired
private ShopsBrandsService shopsBrandsService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_SHOPS;
return null;
}
@Override
... ... @@ -40,7 +42,7 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(buildSearchEvent(EventReportEnum.SHOPSBRADNSMQLISTENER_ONMESSAGE,e));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SHOPSBRADNSMQLISTENER_ONMESSAGE, e));
Thread.sleep(1000);
throw e;
}
... ... @@ -68,5 +70,4 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel
shopsBrandsService.delete(Integer.valueOf(id));
logger.info("[func=deleteData][step=deleteFromDb][indexName={}] [id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));
}
}
... ...
... ... @@ -12,28 +12,24 @@ import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class StandardMqListener extends AbstractMqListener implements ChannelAwareMessageListener, ApplicationEventPublisherAware {
public class StandardMqListener extends AbstractMqListener implements ChannelAwareMessageListener{
private static final Logger logger = LoggerFactory.getLogger(StandardMqListener.class);
private static final Logger SEARCH_EVENT_LOG = LoggerFactory.getLogger("SEARCH_EVENT_LOG");
@Autowired
private StandardService standardService;
protected ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
public String getIndexName() {
return null;
}
@Autowired
private StandardService standardService;
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
... ... @@ -70,8 +66,5 @@ public class StandardMqListener extends AbstractMqListener implements ChannelAwa
logger.info("[func=deleteData][id={}][cost={}ms]", id, (System.currentTimeMillis() - begin));
}
@Override
public String getIndexName() {
return null;
}
}
... ...
... ... @@ -25,6 +25,7 @@ import java.util.Map;
public class BrandMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(BrandMqListener.class);
@Autowired
private BrandService brandService;
@Autowired
... ...
... ... @@ -33,7 +33,6 @@ public class ProductSortMqListener extends AbstractMqListener implements Channel
@Autowired
private TblProductNewIndexBuilder tblProductNewIndexBuilder;
@Override
public void finish() {
productIndexIndexBuilder.init();
... ...
... ... @@ -94,6 +94,4 @@ public class PromotionProductFlagsMqListener extends AbstractMqListener implemen
logger.info("[func=updateIndex][id={}][cost={}ms]", id, System.currentTimeMillis() - begin);
}
}
}
... ...
... ... @@ -38,6 +38,11 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_CONVERSION;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
... ... @@ -97,8 +102,5 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem
}
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_CONVERSION;
}
}
... ...
... ... @@ -43,6 +43,11 @@ public class SuggestWordCustomMqListener extends AbstractMqListener implements C
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_SUGGEST;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
... ... @@ -125,9 +130,6 @@ public class SuggestWordCustomMqListener extends AbstractMqListener implements C
}
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_SUGGEST;
}
}
... ...
... ... @@ -33,6 +33,11 @@ public class ProductExtMqListener extends AbstractMqListener implements ChannelA
@Autowired
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
... ... @@ -88,8 +93,5 @@ public class ProductExtMqListener extends AbstractMqListener implements ChannelA
logger.info("[func=deleteData][indexName={}][skn={}][cost={}ms]", indexName, skn, (System.currentTimeMillis() - begin));
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
}
... ...
... ... @@ -28,6 +28,11 @@ public class ProductSearchMqListener extends AbstractMqListener implements Chann
@Autowired
private ProductService productService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
... ... @@ -82,10 +87,7 @@ public class ProductSearchMqListener extends AbstractMqListener implements Chann
(System.currentTimeMillis() - begin));
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
private void updateProductIndex(ProductSearch productSearch, String key, long begin) {
// 1、参数校验
... ...
... ... @@ -25,6 +25,11 @@ public class ProductStandardRelationMqListener extends AbstractMqListener implem
@Autowired
private ProductStandardRelationService productStandardRelationService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
... ... @@ -109,8 +114,5 @@ public class ProductStandardRelationMqListener extends AbstractMqListener implem
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
}
... ...
... ... @@ -19,8 +19,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
... ... @@ -32,7 +30,7 @@ import java.util.Map;
* Created by wangnan on 2016/11/24.
*/
@Component
public class ProductTimingMqListener extends AbstractMqListener implements ChannelAwareMessageListener, ApplicationEventPublisherAware {
public class ProductTimingMqListener extends AbstractMqListener implements ChannelAwareMessageListener{
private static final Logger logger = LoggerFactory.getLogger(ProductTimingMqListener.class);
... ... @@ -45,11 +43,10 @@ public class ProductTimingMqListener extends AbstractMqListener implements Chann
@Autowired
private StorageUpdateTimeLogicService storageUpdateTimeLogicService;
protected ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
... ... @@ -121,8 +118,4 @@ public class ProductTimingMqListener extends AbstractMqListener implements Chann
this.updateProductIndexWithDataMap(indexData, productId, null, begin);
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
}
... ...