添加消息中间件日志交换机 & 修改不规范的代码

This commit is contained in:
udf_admin@163.com
2017-12-10 14:33:29 +08:00
parent decb28b976
commit 879025944a
14 changed files with 92 additions and 58 deletions
@@ -6,13 +6,13 @@
*/
package org.itkk.udf.amqp.rabbitmq;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* 描述 : RabbitMq配置
*
@@ -47,4 +47,24 @@ public class RabbitMqConfig {
return new Jackson2JsonMessageConverter(objectMapper);
}
/**
* exchangeMessageLog
*
* @return DirectExchange
*/
@Bean
public DirectExchange exchangeMessageLog() {
return new DirectExchange(RabbitmqConstant.EXCHANGE_MESSAGE_LOG.class.getSimpleName(), true, false);
}
/**
* exchangeMessageLogDlx
*
* @return DirectExchange
*/
@Bean
public DirectExchange exchangeMessageLogDlx() {
return new DirectExchange(RabbitmqConstant.EXCHANGE_MESSAGE_LOG_DLX.class.getSimpleName(), true, false);
}
}
@@ -23,6 +23,20 @@ public class RabbitmqConstant {
*/
public static final String X_DEAD_LETTER_ROUTING_KEY = "x-dead-letter-routing-key";
/**
* (EXCHANGE)消息记录
*/
public enum EXCHANGE_MESSAGE_LOG {
}
/**
* (EXCHANGE)消息记录(死信)
*/
public enum EXCHANGE_MESSAGE_LOG_DLX {
}
/**
* 描述 : 私有化构造函数
*/
@@ -23,7 +23,7 @@ import java.io.IOException;
public class XssFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
public void init(FilterConfig filterConfig) {
log.debug("(XssFilter) initialize");
}
@@ -25,25 +25,25 @@ public class Page<E> implements Serializable {
* 当前页,默认1
*/
@ApiModelProperty(value = "当前页", required = true, dataType = "int")
private int curPage = 1;
private int curPage;
/**
* 每页数量,默认0
*/
@ApiModelProperty(value = "每页行数", required = true, dataType = "int")
private int pageSize = 0;
private int pageSize;
/**
* 总页数
*/
@ApiModelProperty(value = "总页数", required = true, dataType = "long")
private long totalPages = 0;
private long totalPages;
/**
* 总条数
*/
@ApiModelProperty(value = "总行数", required = true, dataType = "long")
private long totalRecords = 0;
private long totalRecords;
/**
* 结果集
@@ -54,7 +54,7 @@ public class OssWarpper {
public PolicyResult getPolicy(String code) throws UnsupportedEncodingException {
//判空
if (!aliyunOssProperties.getAuth().containsKey(code) || !aliyunOssProperties.getPath().containsKey(code)) {
throw new ParameterValidException("aliyun oss code:" + code + "未定义", null);
throw new ParameterValidException("aliyun oss code:" + code + "未定义", null); //NOSONAR
}
//获得认证信息 和 路径信息
AliyunOssAccessMeta auth = aliyunOssProperties.getAuth().get(code);
@@ -68,13 +68,13 @@ public class DrawOptions {
return true;
}
if (expandType == ExpandType.SIZE4) {
return size4Img != null;
} else if (expandType == ExpandType.COL2) {
return col2img != null;
} else {
return row2Img != null;
switch (expandType) {
case SIZE4:
return size4Img != null;
case COL2:
return col2img != null;
default:
return row2Img != null;
}
}
}
@@ -75,7 +75,7 @@ public class Rms {
* @param <O> 输出类型
* @return 服务结果
*/
public <I, O> ResponseEntity<O> call(String host, int port, String serviceCode, HttpHeaders headers, I input, String uriParam, ParameterizedTypeReference<O> responseType, Map<String, ?> uriVariables) {
public <I, O> ResponseEntity<O> call(String host, int port, String serviceCode, HttpHeaders headers, I input, String uriParam, ParameterizedTypeReference<O> responseType, Map<String, ?> uriVariables) { //NOSONAR
//客户端权限验证
verification(serviceCode);
//获取服务元数据
@@ -127,14 +127,12 @@ public class RmsAuthHandlerInterceptor implements HandlerInterceptor {
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
log.debug("SystemTagAuthHandlerInterceptor.postHandle");
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
log.debug("SystemTagAuthHandlerInterceptor.afterCompletion");
}
@@ -34,7 +34,7 @@ public enum RmsJobStats {
* Field value: 参数值
* </p>
*/
private Integer value = null;
private Integer value;
/**
* <p>
@@ -42,7 +42,7 @@ public enum TriggerDataMapKey {
* Field value: 参数值
* </p>
*/
private String value = null;
private String value;
/**
* <p>
@@ -30,7 +30,7 @@ public enum TriggerType {
* Field value: 参数值
* </p>
*/
private String value = null;
private String value;
/**
* <p>
@@ -6,11 +6,9 @@
*/
package org.itkk.udf.scheduler.job;
import org.itkk.udf.scheduler.IListenerEvent;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.itkk.udf.scheduler.IListenerEvent;
/**
* <p>
@@ -30,8 +28,7 @@ import org.itkk.udf.scheduler.IListenerEvent;
public class ClearScheduledLog extends AbstractBaseJob {
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext)
throws JobExecutionException {
protected void executeInternal(JobExecutionContext jobExecutionContext) {
IListenerEvent listenerLog = this.getApplicationContext().getBean(IListenerEvent.class);
if (listenerLog != null) {
listenerLog.clearScheduledLog();
@@ -6,11 +6,9 @@
*/
package org.itkk.udf.scheduler.job;
import org.itkk.udf.scheduler.IListenerEvent;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.itkk.udf.scheduler.IListenerEvent;
/**
* <p>
@@ -30,8 +28,7 @@ import org.itkk.udf.scheduler.IListenerEvent;
public class ClearScheduledTriggerLog extends AbstractBaseJob {
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext)
throws JobExecutionException {
protected void executeInternal(JobExecutionContext jobExecutionContext) {
IListenerEvent triggerLog = this.getApplicationContext().getBean(IListenerEvent.class);
if (triggerLog != null) {
triggerLog.clearScheduledTriggerLog();
@@ -173,14 +173,18 @@ public class TriggerService {
// 时区
cronTriggerBuilder.inTimeZone(TimeZone.getTimeZone(triggerMeta.getTimeZoneId()));
// 设置触发机制 默认 SimpleTrigger.MISFIRE_INSTRUCTION_SMART_POLICY
if (CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING == triggerMeta.getMisfireInstruction()) {
cronTriggerBuilder.withMisfireHandlingInstructionDoNothing();
} else if (CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW == triggerMeta
.getMisfireInstruction()) {
cronTriggerBuilder.withMisfireHandlingInstructionFireAndProceed();
} else if (CronTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY == triggerMeta
.getMisfireInstruction()) {
cronTriggerBuilder.withMisfireHandlingInstructionIgnoreMisfires();
switch (triggerMeta.getMisfireInstruction()) {
case CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING:
cronTriggerBuilder.withMisfireHandlingInstructionDoNothing();
break;
case CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW:
cronTriggerBuilder.withMisfireHandlingInstructionFireAndProceed();
break;
case CronTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY:
cronTriggerBuilder.withMisfireHandlingInstructionIgnoreMisfires();
break;
default:
break;
}
// 将cronTrigger设置到triggerBuilder中
triggerBuilder.withSchedule(cronTriggerBuilder);
@@ -245,23 +249,27 @@ public class TriggerService {
// 重复时间
simpleTriggerBuilder.withIntervalInMilliseconds(triggerMeta.getIntervalInMilliseconds());
// 设置触发机制 默认 SimpleTrigger.MISFIRE_INSTRUCTION_SMART_POLICY
if (SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW == triggerMeta.getMisfireInstruction()) {
simpleTriggerBuilder.withMisfireHandlingInstructionFireNow();
} else if (SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT == triggerMeta
.getMisfireInstruction()) {
simpleTriggerBuilder.withMisfireHandlingInstructionNextWithExistingCount();
} else if (SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT == triggerMeta
.getMisfireInstruction()) {
simpleTriggerBuilder.withMisfireHandlingInstructionNextWithRemainingCount();
} else if (SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT == triggerMeta
.getMisfireInstruction()) {
simpleTriggerBuilder.withMisfireHandlingInstructionNowWithExistingCount();
} else if (SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT == triggerMeta
.getMisfireInstruction()) {
simpleTriggerBuilder.withMisfireHandlingInstructionNowWithRemainingCount();
} else if (SimpleTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY == triggerMeta
.getMisfireInstruction()) {
simpleTriggerBuilder.withMisfireHandlingInstructionIgnoreMisfires();
switch (triggerMeta.getMisfireInstruction()) {
case SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW:
simpleTriggerBuilder.withMisfireHandlingInstructionFireNow();
break;
case SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT:
simpleTriggerBuilder.withMisfireHandlingInstructionNextWithExistingCount();
break;
case SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT:
simpleTriggerBuilder.withMisfireHandlingInstructionNextWithRemainingCount();
break;
case SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT:
simpleTriggerBuilder.withMisfireHandlingInstructionNowWithExistingCount();
break;
case SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT:
simpleTriggerBuilder.withMisfireHandlingInstructionNowWithRemainingCount();
break;
case SimpleTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY:
simpleTriggerBuilder.withMisfireHandlingInstructionIgnoreMisfires();
break;
default:
break;
}
// 将SimpleTrigger设置到triggerBuilder中
triggerBuilder.withSchedule(simpleTriggerBuilder);