![JAR search and dependency download from the Maven repository](/logo.png)
com.github.brainlag.nsq.frames.MessageFrame Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nsq-client Show documentation
Show all versions of nsq-client Show documentation
Fast Java client for NSQ.
The newest version!
package com.github.brainlag.nsq.frames;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class MessageFrame extends NSQFrame {
private long timestamp;
private int attempts;
private byte[] messageId = new byte[16];
private byte[] messageBody;
@Override
public void setData(byte[] bytes) {
//parse the bytes
super.setData(bytes);
ByteBuf buf = Unpooled.wrappedBuffer(bytes);
timestamp = buf.readLong();
attempts = buf.readShort();
buf.readBytes(messageId);
ByteBuf messageBodyBuf = buf.readBytes(buf.readableBytes());
if (messageBodyBuf.hasArray()) {
messageBody = messageBodyBuf.array();
} else {
byte[] array = new byte[messageBodyBuf.readableBytes()];
messageBodyBuf.readBytes(array);
messageBody = array;
}
buf.release();
messageBodyBuf.release();
}
public long getTimestamp() {
return timestamp;
}
public int getAttempts() {
return attempts;
}
public byte[] getMessageId() {
return messageId;
}
public byte[] getMessageBody() {
return messageBody;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy