2024-10-08 09:38:54 +08:00
|
|
|
|
/**
|
2025-03-04 10:42:17 +08:00
|
|
|
|
* 开源代码,仅供学习和交流研究使用,商用请联系三丙
|
|
|
|
|
|
* 微信:mohan_88888
|
|
|
|
|
|
* 抖音:程序员三丙
|
2026-06-10 14:26:04 +08:00
|
|
|
|
* 付费课程:https://www.bilibili.com/cheese/play/ss942400790
|
2024-10-08 09:38:54 +08:00
|
|
|
|
*/
|
|
|
|
|
|
package sanbing.jcpp.infrastructure.queue;
|
|
|
|
|
|
|
2024-10-23 17:07:57 +08:00
|
|
|
|
import com.google.protobuf.GeneratedMessage;
|
2024-10-08 09:38:54 +08:00
|
|
|
|
import lombok.Data;
|
|
|
|
|
|
|
|
|
|
|
|
@Data
|
2024-10-23 17:07:57 +08:00
|
|
|
|
public class ProtoQueueMsg<T extends GeneratedMessage> implements QueueMsg {
|
2024-10-08 09:38:54 +08:00
|
|
|
|
|
|
|
|
|
|
private final String key;
|
|
|
|
|
|
protected final T value;
|
|
|
|
|
|
private final QueueMsgHeaders headers;
|
|
|
|
|
|
|
|
|
|
|
|
public ProtoQueueMsg(String key, T value) {
|
|
|
|
|
|
this(key, value, new DefaultQueueMsgHeaders());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ProtoQueueMsg(String key, T value, QueueMsgHeaders headers) {
|
|
|
|
|
|
this.key = key;
|
|
|
|
|
|
this.value = value;
|
|
|
|
|
|
this.headers = headers;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getKey() {
|
|
|
|
|
|
return key;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public QueueMsgHeaders getHeaders() {
|
|
|
|
|
|
return headers;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public byte[] getData() {
|
|
|
|
|
|
return value.toByteArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|