本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.getBytes方法的具体用法?Java ActiveMQBuffer.getBytes怎么用?Java ActiveMQBuffer.getBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.artemis.api.core.ActiveMQBuffer
的用法示例。
在下文中一共展示了ActiveMQBuffer.getBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: broadcastConnectors
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public synchronized void broadcastConnectors() throws Exception {
ActiveMQBuffer buff = ActiveMQBuffers.dynamicBuffer(4096);
buff.writeString(nodeManager.getNodeId().toString());
buff.writeString(uniqueID);
buff.writeInt(connectors.size());
for (TransportConfiguration tcConfig : connectors) {
tcConfig.encode(buff);
}
// Only send as many bytes as we need.
byte[] data = new byte[buff.readableBytes()];
buff.getBytes(buff.readerIndex(), data);
endpoint.broadcast(data);
}
示例2: write
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void write(final ActiveMQBuffer bytes, final boolean sync, final IOCallback callback) throws IOException {
if (timedBuffer != null) {
bytes.setIndex(0, bytes.capacity());
timedBuffer.addBytes(bytes, sync, callback);
} else {
final int readableBytes = bytes.readableBytes();
final ByteBuffer buffer = factory.newBuffer(readableBytes);
//factory::newBuffer doesn't necessary return a buffer with limit == readableBytes!!
buffer.limit(readableBytes);
bytes.getBytes(bytes.readerIndex(), buffer);
buffer.flip();
writeDirect(buffer, sync, callback);
}
}
示例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: testValidateUTFWithChars
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void testValidateUTFWithChars(final int size, final char c) {
final char[] chars = new char[size];
Arrays.fill(chars, c);
final String expectedUtf8String = new String(chars);
final ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(4 * chars.length);
UTF8Util.saveUTF(buffer.byteBuf(), expectedUtf8String);
final byte[] expectedBytes = expectedUtf8String.getBytes(StandardCharsets.UTF_8);
final int encodedSize = buffer.readUnsignedShort();
final byte[] realEncodedBytes = new byte[encodedSize];
buffer.getBytes(buffer.readerIndex(), realEncodedBytes);
Assert.assertArrayEquals(expectedBytes, realEncodedBytes);
}
示例5: testGetBytesILChannelBufferII
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Test
public void testGetBytesILChannelBufferII() throws Exception {
LargeMessageControllerImpl buffer = create15BytesSample();
ActiveMQBuffer dstBuffer = ActiveMQBuffers.fixedBuffer(20);
dstBuffer.setIndex(0, 5);
buffer.getBytes(0, dstBuffer);
byte[] compareBytes = new byte[15];
dstBuffer.getBytes(5, compareBytes);
validateAgainstSample(compareBytes);
}