本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.resetReaderIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.resetReaderIndex方法的具体用法?Java ActiveMQBuffer.resetReaderIndex怎么用?Java ActiveMQBuffer.resetReaderIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.artemis.api.core.ActiveMQBuffer
的用法示例。
在下文中一共展示了ActiveMQBuffer.resetReaderIndex方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReadUTF
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Test
public void testReadUTF() throws Exception {
ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(10 * 1024);
buffer.writeUTF(str);
for (int c = 0; c < TIMES; c++) {
ThreadLeakCheckRule.forceGC();
final long start = System.currentTimeMillis();
for (long i = 0; i < numberOfIteractions; i++) {
buffer.resetReaderIndex();
String newstr = buffer.readUTF();
Assert.assertEquals(str, newstr);
blackHole = newstr;
}
final long spentTime = System.currentTimeMillis() - start;
System.out.println("Time readUTF = " + spentTime + " ms");
System.out.println("Throughput readUTF = " + numberOfIteractions / spentTime + " ops/ms");
}
}
示例2: decode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public StompFrame decode(ActiveMQBuffer buffer) throws ActiveMQStompException {
StompFrame frame = null;
try {
frame = frameHandler.decode(buffer);
} catch (ActiveMQStompException e) {
switch (e.getCode()) {
case ActiveMQStompException.INVALID_EOL_V10:
if (version != null)
throw e;
frameHandler = new StompFrameHandlerV12(this, scheduledExecutorService, factory);
buffer.resetReaderIndex();
frame = decode(buffer);
break;
case ActiveMQStompException.INVALID_COMMAND:
case ActiveMQStompException.UNDEFINED_ESCAPE:
frameHandler.onError(e);
break;
default:
throw e;
}
}
return frame;
}
示例3: checkData
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void checkData(JDBCSequentialFile file, ActiveMQBuffer expectedData) throws SQLException {
expectedData.resetReaderIndex();
byte[] resultingBytes = new byte[expectedData.readableBytes()];
ByteBuffer byteBuffer = ByteBuffer.allocate(expectedData.readableBytes());
file.read(byteBuffer, null);
expectedData.getBytes(0, resultingBytes);
assertArrayEquals(resultingBytes, byteBuffer.array());
}
示例4: assertEqualsBuffers
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static void assertEqualsBuffers(final int size, final ActiveMQBuffer expected, final ActiveMQBuffer actual) {
// assertEquals(expected.length, actual.length);
expected.readerIndex(0);
actual.readerIndex(0);
for (int i = 0; i < size; i++) {
byte b1 = expected.readByte();
byte b2 = actual.readByte();
Assert.assertEquals("byte at index " + i, b1, b2);
}
expected.resetReaderIndex();
actual.resetReaderIndex();
}
示例5: doBeforeReceive
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public void doBeforeReceive() throws ActiveMQException {
message.checkCompletion();
ActiveMQBuffer body = message.getBodyBuffer();
if (body != null) {
body.resetReaderIndex();
}
}
示例6: bytesMessageReset
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static void bytesMessageReset(ActiveMQBuffer message) {
message.resetReaderIndex();
}
示例7: readBodyMap
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
* Utility method to set the map on a message body
*/
public static void readBodyMap(ActiveMQBuffer message, TypedProperties map) {
message.resetReaderIndex();
map.decode(message.byteBuf());
}
示例8: readBodyText
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
* Utility method to set the Text message on a message body
*/
public static SimpleString readBodyText(ActiveMQBuffer buff) {
buff.resetReaderIndex();
return buff.readNullableSimpleString();
}