com.github.lontime.extredisson.consumer.ReferenceMessage Maven / Gradle / Ivy
The newest version!
package com.github.lontime.extredisson.consumer;
import java.util.List;
import com.github.lontime.base.serial.model.Header;
import com.github.lontime.extredisson.common.Constants;
/**
* ReferenceMessage.
* @author lontime
* @since 1.0
*/
public class ReferenceMessage {
private String realMsgId;
private String realTopic;
public String getRealMsgId() {
return realMsgId;
}
public void setRealMsgId(String realMsgId) {
this.realMsgId = realMsgId;
}
public String getRealTopic() {
return realTopic;
}
public void setRealTopic(String realTopic) {
this.realTopic = realTopic;
}
public static ReferenceMessage createFromHeader(List headers) {
final ReferenceMessage message = new ReferenceMessage();
for (Header header : headers) {
if (Constants.HEADER_REAL_MSG_ID.equals(header.getKey())) {
message.setRealMsgId(header.getValue());
} else if (Constants.HEADER_REAL_TOPIC.equals(header.getKey())) {
message.setRealTopic(header.getValue());
}
}
if (message.getRealMsgId() == null || message.getRealTopic() == null) {
return null;
}
return message;
}
}