pull/43/head
3y 1 year ago
parent 72efb13d0d
commit b0e086c2d3

@ -8,7 +8,10 @@ import com.java3y.austin.support.domain.MessageTemplate;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.ExchangeTypes; import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*; import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -24,6 +27,9 @@ import java.util.List;
@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.RABBIT_MQ) @ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.RABBIT_MQ)
public class RabbitMqReceiver { public class RabbitMqReceiver {
private static final String MSG_TYPE_SEND = "send";
private static final String MSG_TYPE_RECALL = "recall";
@Autowired @Autowired
private ConsumeService consumeService; private ConsumeService consumeService;
@ -39,11 +45,11 @@ public class RabbitMqReceiver {
if (StringUtils.isBlank(messageContent)) { if (StringUtils.isBlank(messageContent)) {
return; return;
} }
if ("send".equals(messageType)) { if (MSG_TYPE_SEND.equals(messageType)) {
// 处理发送消息 // 处理发送消息
List<TaskInfo> taskInfoLists = JSON.parseArray(messageContent, TaskInfo.class); List<TaskInfo> taskInfoLists = JSON.parseArray(messageContent, TaskInfo.class);
consumeService.consume2Send(taskInfoLists); consumeService.consume2Send(taskInfoLists);
} else if ("recall".equals(messageType)) { } else if (MSG_TYPE_RECALL.equals(messageType)) {
// 处理撤回消息 // 处理撤回消息
MessageTemplate messageTemplate = JSON.parseObject(messageContent, MessageTemplate.class); MessageTemplate messageTemplate = JSON.parseObject(messageContent, MessageTemplate.class);
consumeService.consume2recall(messageTemplate); consumeService.consume2recall(messageTemplate);

@ -1,7 +1,5 @@
package com.java3y.austin.support.utils; package com.java3y.austin.support.utils;
import org.springframework.context.expression.MapAccessor;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.util.PropertyPlaceholderHelper; import org.springframework.util.PropertyPlaceholderHelper;
import java.text.MessageFormat; import java.text.MessageFormat;
@ -25,20 +23,11 @@ public class ContentHolderUtil {
*/ */
private static final String PLACE_HOLDER_SUFFIX = "}"; private static final String PLACE_HOLDER_SUFFIX = "}";
private static final StandardEvaluationContext EVALUATION_CONTEXT; private static final PropertyPlaceholderHelper PROPERTY_PLACEHOLDER_HELPER = new PropertyPlaceholderHelper(PLACE_HOLDER_PREFIX, PLACE_HOLDER_SUFFIX);
private static final PropertyPlaceholderHelper PROPERTY_PLACEHOLDER_HELPER = new PropertyPlaceholderHelper(
PLACE_HOLDER_PREFIX, PLACE_HOLDER_SUFFIX);
static {
EVALUATION_CONTEXT = new StandardEvaluationContext();
EVALUATION_CONTEXT.addPropertyAccessor(new MapAccessor());
}
public static String replacePlaceHolder(final String template, final Map<String, String> paramMap) { public static String replacePlaceHolder(final String template, final Map<String, String> paramMap) {
String replacedPushContent = PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders(template, return PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders(template, new CustomPlaceholderResolver(template, paramMap));
new CustomPlaceholderResolver(template, paramMap));
return replacedPushContent;
} }
private static class CustomPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver { private static class CustomPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver {
@ -55,8 +44,7 @@ public class ContentHolderUtil {
public String resolvePlaceholder(String placeholderName) { public String resolvePlaceholder(String placeholderName) {
String value = paramMap.get(placeholderName); String value = paramMap.get(placeholderName);
if (null == value) { if (null == value) {
String errorStr = MessageFormat.format("template:{0} require param:{1},but not exist! paramMap:{2}", String errorStr = MessageFormat.format("template:{0} require param:{1},but not exist! paramMap:{2}", template, placeholderName, paramMap.toString());
template, placeholderName, paramMap.toString());
throw new IllegalArgumentException(errorStr); throw new IllegalArgumentException(errorStr);
} }
return value; return value;

@ -5,7 +5,6 @@ import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.cron.handler.RefreshDingDingAccessTokenHandler; import com.java3y.austin.cron.handler.RefreshDingDingAccessTokenHandler;
import com.java3y.austin.cron.handler.RefreshGeTuiAccessTokenHandler; import com.java3y.austin.cron.handler.RefreshGeTuiAccessTokenHandler;
import com.java3y.austin.web.annotation.AustinAspect; import com.java3y.austin.web.annotation.AustinAspect;
import com.java3y.austin.web.annotation.AustinResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

Loading…
Cancel
Save