Files
JChargePointProtocol/jcpp-infrastructure-queue/src/main/java/sanbing/jcpp/infrastructure/queue/ProtoQueueMsg.java
2026-06-10 14:26:04 +08:00

44 lines
1020 B
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 开源代码,仅供学习和交流研究使用,商用请联系三丙
* 微信mohan_88888
* 抖音:程序员三丙
* 付费课程https://www.bilibili.com/cheese/play/ss942400790
*/
package sanbing.jcpp.infrastructure.queue;
import com.google.protobuf.GeneratedMessage;
import lombok.Data;
@Data
public class ProtoQueueMsg<T extends GeneratedMessage> implements QueueMsg {
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();
}
}