feat: 抽象消息接收者接口,方便管理与拓展

pull/63/head
xiaoxiamo 5 months ago
parent 0fba9367c9
commit 4c884afdb5

@ -0,0 +1,11 @@
package com.java3y.austin.handler.receiver;
/**
*
*
* @author xiaoxiamao
* @date 2024/06/16
*/
public interface MessageReceiver {
}

@ -3,6 +3,7 @@ package com.java3y.austin.handler.receiver.eventbus;
import com.google.common.eventbus.Subscribe;
import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.handler.receiver.MessageReceiver;
import com.java3y.austin.handler.receiver.service.ConsumeService;
import com.java3y.austin.support.constans.MessageQueuePipeline;
import com.java3y.austin.support.mq.eventbus.EventBusListener;
@ -17,7 +18,7 @@ import java.util.List;
*/
@Component
@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.EVENT_BUS)
public class EventBusReceiver implements EventBusListener {
public class EventBusReceiver implements EventBusListener, MessageReceiver {
@Autowired
private ConsumeService consumeService;

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.handler.receiver.MessageReceiver;
import com.java3y.austin.handler.receiver.service.ConsumeService;
import com.java3y.austin.handler.utils.GroupIdMappingUtils;
import com.java3y.austin.support.constans.MessageQueuePipeline;
@ -29,7 +30,7 @@ import java.util.Optional;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.KAFKA)
public class Receiver {
public class Receiver implements MessageReceiver {
@Autowired
private ConsumeService consumeService;

@ -3,6 +3,7 @@ package com.java3y.austin.handler.receiver.rabbit;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.handler.receiver.MessageReceiver;
import com.java3y.austin.handler.receiver.service.ConsumeService;
import com.java3y.austin.support.constans.MessageQueuePipeline;
import org.apache.commons.lang3.StringUtils;
@ -25,7 +26,7 @@ import java.util.List;
*/
@Component
@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.RABBIT_MQ)
public class RabbitMqReceiver {
public class RabbitMqReceiver implements MessageReceiver {
private static final String MSG_TYPE_SEND = "send";
private static final String MSG_TYPE_RECALL = "recall";

@ -2,6 +2,7 @@ package com.java3y.austin.handler.receiver.rocketmq;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.handler.receiver.MessageReceiver;
import com.java3y.austin.handler.receiver.service.ConsumeService;
import com.java3y.austin.support.constans.MessageQueuePipeline;
import org.apache.commons.lang3.StringUtils;
@ -27,7 +28,7 @@ import java.util.List;
selectorType = SelectorType.TAG,
selectorExpression = "${austin.business.tagId.value}"
)
public class RocketMqBizReceiver implements RocketMQListener<String> {
public class RocketMqBizReceiver implements RocketMQListener<String>, MessageReceiver {
@Autowired
private ConsumeService consumeService;

@ -2,6 +2,7 @@ package com.java3y.austin.handler.receiver.rocketmq;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.handler.receiver.MessageReceiver;
import com.java3y.austin.handler.receiver.service.ConsumeService;
import com.java3y.austin.support.constans.MessageQueuePipeline;
import org.apache.commons.lang3.StringUtils;
@ -25,7 +26,7 @@ import org.springframework.stereotype.Component;
selectorType = SelectorType.TAG,
selectorExpression = "${austin.business.tagId.value}"
)
public class RocketMqRecallReceiver implements RocketMQListener<String> {
public class RocketMqRecallReceiver implements RocketMQListener<String>, MessageReceiver {
@Autowired
private ConsumeService consumeService;

@ -3,6 +3,7 @@ package com.java3y.austin.handler.receiver.springeventbus;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.handler.receiver.MessageReceiver;
import com.java3y.austin.support.constans.MessageQueuePipeline;
import com.java3y.austin.support.mq.springeventbus.AustinSpringEventBusEvent;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,7 +20,7 @@ import org.springframework.stereotype.Service;
*/
@Service
@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.SPRING_EVENT_BUS)
public class SpringEventBusReceiverListener implements ApplicationListener<AustinSpringEventBusEvent> {
public class SpringEventBusReceiverListener implements ApplicationListener<AustinSpringEventBusEvent>, MessageReceiver {
@Autowired
private SpringEventBusReceiver springEventBusReceiver;

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save