本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.readBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.readBytes方法的具体用法?Java ActiveMQBuffer.readBytes怎么用?Java ActiveMQBuffer.readBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.artemis.api.core.ActiveMQBuffer
的用法示例。
在下文中一共展示了ActiveMQBuffer.readBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: streamReadBytes
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
* Utility for reading bytes out of streaming.
* It will return remainingBytes, bytesRead
*
* @param remainingBytes remaining Bytes from previous read. Send it to 0 if it was the first call for the message
* @param buff
* @return a pair of remaining bytes and bytes read
*/
public static Pair<Integer, Integer> streamReadBytes(ActiveMQBuffer buff, int remainingBytes, byte[] value) {
if (remainingBytes == -1) {
return new Pair<>(0, -1);
} else if (remainingBytes == 0) {
byte type = buff.readByte();
if (type != DataConstants.BYTES) {
throw new IllegalStateException("Invalid conversion");
}
remainingBytes = buff.readInt();
}
int read = Math.min(value.length, remainingBytes);
buff.readBytes(value, 0, read);
remainingBytes -= read;
if (remainingBytes == 0) {
remainingBytes = -1;
}
return new Pair<>(remainingBytes, read);
}
示例2: decodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
fileId = buffer.readLong();
switch (FileType.getFileType(buffer.readByte())) {
case JOURNAL: {
journalType = AbstractJournalStorageManager.JournalContent.getType(buffer.readByte());
fileType = FileType.JOURNAL;
break;
}
case PAGE: {
pageStoreName = buffer.readSimpleString();
fileType = FileType.PAGE;
break;
}
case LARGE_MESSAGE: {
fileType = FileType.LARGE_MESSAGE;
break;
}
}
int size = buffer.readInt();
if (size > 0) {
byteArray = new byte[size];
buffer.readBytes(byteArray);
}
}
示例3: encodeMessageBody
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
* Base64 encode a ServerMessage body into the proper XML format
*/
static String encodeMessageBody(final Message message) throws Exception {
Preconditions.checkNotNull(message, "ServerMessage can not be null");
ActiveMQBuffer byteBuffer = message.toCore().getReadOnlyBodyBuffer();
byte[] buffer = new byte[byteBuffer.writerIndex()];
byteBuffer.readBytes(buffer);
return XmlDataExporterUtil.encode(buffer);
}
示例4: getFields
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public Map<String, Object> getFields(MessageReference ref) throws OpenDataException {
Map<String, Object> rc = super.getFields(ref);
ICoreMessage m = ref.getMessage().toCore();
if (!m.isLargeMessage()) {
ActiveMQBuffer bodyCopy = m.getReadOnlyBodyBuffer();
byte[] bytes = new byte[bodyCopy.readableBytes()];
bodyCopy.readBytes(bytes);
rc.put(CompositeDataConstants.BODY, bytes);
} else {
rc.put(CompositeDataConstants.BODY, new byte[0]);
}
return rc;
}
示例5: decodeXid
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static Xid decodeXid(final ActiveMQBuffer in) {
int formatID = in.readInt();
byte[] bq = new byte[in.readInt()];
in.readBytes(bq);
byte[] gtxid = new byte[in.readInt()];
in.readBytes(gtxid);
Xid xid = new XidImpl(bq, formatID, gtxid);
return xid;
}
示例6: bytesReadBytes
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static int bytesReadBytes(ActiveMQBuffer message, final byte[] value, final int length) {
if (!message.readable()) {
return -1;
}
int read = Math.min(length, message.readableBytes());
if (read != 0) {
message.readBytes(value, 0, read);
}
return read;
}
示例7: streamReadObject
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static Object streamReadObject(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.BOOLEAN:
return buff.readBoolean();
case DataConstants.BYTE:
return buff.readByte();
case DataConstants.SHORT:
return buff.readShort();
case DataConstants.CHAR:
return (char) buff.readShort();
case DataConstants.INT:
return buff.readInt();
case DataConstants.LONG:
return buff.readLong();
case DataConstants.FLOAT:
return Float.intBitsToFloat(buff.readInt());
case DataConstants.DOUBLE:
return Double.longBitsToDouble(buff.readLong());
case DataConstants.STRING:
return buff.readNullableString();
case DataConstants.BYTES:
int bufferLen = buff.readInt();
byte[] bytes = new byte[bufferLen];
buff.readBytes(bytes);
return bytes;
default:
throw new IllegalStateException("Invalid conversion");
}
}
示例8: decodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
int size = buffer.readInt();
body = new byte[size];
buffer.readBytes(body);
continues = buffer.readBoolean();
}
示例9: decodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
journalID = buffer.readByte();
operation = ADD_OPERATION_TYPE.toOperation(buffer.readBoolean());
id = buffer.readLong();
journalRecordType = buffer.readByte();
final int recordDataSize = buffer.readInt();
recordData = new byte[recordDataSize];
buffer.readBytes(recordData);
}
示例10: decode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public synchronized StompFrame decode(final ActiveMQBuffer buffer) throws ActiveMQStompException {
int readable = buffer.readableBytes();
if (data + readable >= workingBuffer.length) {
resizeWorking(data + readable);
}
buffer.readBytes(workingBuffer, data, readable);
data += readable;
if (command == null) {
if (!parseCommand()) {
return null;
}
}
//if command is not null, should it automatically be in
//reading headers mode? think of get rid of readingHeaders flag
if (readingHeaders) {
if (!parseHeaders()) {
return null;
}
}
// Now the body
StompFrame ret = parseBody();
return ret;
}
示例11: messageToLargeMessage
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private LargeServerMessage messageToLargeMessage(Message message) throws Exception {
ICoreMessage coreMessage = message.toCore();
LargeServerMessage lsm = getStorageManager().createLargeMessage(storageManager.generateID(), coreMessage);
ActiveMQBuffer buffer = coreMessage.getReadOnlyBodyBuffer();
byte[] body = new byte[buffer.readableBytes()];
buffer.readBytes(body);
lsm.addBytes(body);
lsm.releaseResources();
lsm.putLongProperty(Message.HDR_LARGE_BODY_SIZE, body.length);
return lsm;
}
示例12: reloadPersistence
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void reloadPersistence(ActiveMQBuffer record) {
int size = record.readInt();
byte[] recordArray = new byte[size];
record.readBytes(recordArray);
this.messagePaylodStart = 0; // whatever was persisted will be sent
this.data = Unpooled.wrappedBuffer(recordArray);
this.bufferValid = true;
this.durable = true; // it's coming from the journal, so it's durable
parseHeaders();
}
示例13: decodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
journalID = buffer.readByte();
txId = buffer.readLong();
int size = buffer.readInt();
recordData = new byte[size];
buffer.readBytes(recordData);
}
示例14: decode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decode(final ActiveMQBuffer buffer) {
transactionID = buffer.readLong();
boolean isLargeMessage = buffer.readBoolean();
if (isLargeMessage) {
int largeMessageHeaderSize = buffer.readInt();
if (storageManager == null) {
largeMessageLazyData = new byte[largeMessageHeaderSize];
buffer.readBytes(largeMessageLazyData);
} else {
this.message = storageManager.createLargeMessage();
LargeMessagePersister.getInstance().decode(buffer, (LargeServerMessage) message);
((LargeServerMessage) message).incrementDelayDeletionCount();
}
} else {
this.message = MessagePersister.getInstance().decode(buffer, null);
}
int queueIDsSize = buffer.readInt();
queueIDs = new long[queueIDsSize];
for (int i = 0; i < queueIDsSize; i++) {
queueIDs[i] = buffer.readLong();
}
}
示例15: decodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(ActiveMQBuffer buffer) {
super.decodeRest(buffer);
handler = buffer.readSimpleString();
voteBuffer = ActiveMQBuffers.fixedBuffer(buffer.readableBytes());
buffer.readBytes(voteBuffer);
}