You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
738 B
36 lines
738 B
|
2 years ago
|
package com.bx.imcommon.mq;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* redis 队列消费者抽象类
|
||
|
|
*/
|
||
|
|
public abstract class RedisMQConsumer<T> {
|
||
|
|
|
||
|
2 years ago
|
/**
|
||
|
|
* 消费消息回调(单条)
|
||
|
|
*/
|
||
|
2 years ago
|
public void onMessage(T data){}
|
||
|
|
|
||
|
2 years ago
|
/**
|
||
|
|
* 消费消息回调(批量)
|
||
|
|
*/
|
||
|
2 years ago
|
public void onMessage(List<T> datas){}
|
||
|
2 years ago
|
|
||
|
2 years ago
|
/**
|
||
|
|
* 生成redis队列完整key
|
||
|
|
*/
|
||
|
2 years ago
|
public String generateKey(){
|
||
|
|
// 默认队列名就是redis的key
|
||
|
|
RedisMQListener annotation = this.getClass().getAnnotation(RedisMQListener.class);
|
||
|
|
return annotation.queue();
|
||
|
|
}
|
||
|
2 years ago
|
|
||
|
|
/**
|
||
|
|
* 队列是否就绪,返回true才会开始消费
|
||
|
|
*/
|
||
|
|
public Boolean isReady(){
|
||
|
|
return true;
|
||
|
|
}
|
||
|
2 years ago
|
}
|