本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.writeBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.writeBytes方法的具体用法?Java ActiveMQBuffer.writeBytes怎么用?Java ActiveMQBuffer.writeBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.artemis.api.core.ActiveMQBuffer
的用法示例。
在下文中一共展示了ActiveMQBuffer.writeBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMessagesWithPredefinedSize
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void sendMessagesWithPredefinedSize(int numberOfMessages,
ClientSession session,
ClientProducer producer,
int messageSize) throws Exception {
ClientMessage message;
final byte[] body = new byte[messageSize];
ByteBuffer bb = ByteBuffer.wrap(body);
for (int i = 1; i <= messageSize; i++) {
bb.put(getSamplebyte(i));
}
for (int i = 0; i < numberOfMessages; i++) {
message = session.createMessage(true);
ActiveMQBuffer bodyLocal = message.getBodyBuffer();
bodyLocal.writeBytes(body);
producer.send(message);
if (i % 1000 == 0) {
session.commit();
}
}
session.commit();
}
示例2: sendFewMessages
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
protected void sendFewMessages(int numberOfMessages,
ClientSession session,
ClientProducer producer,
byte[] body) throws ActiveMQException {
ClientMessage message;
for (int i = 0; i < numberOfMessages; i++) {
message = session.createMessage(true);
ActiveMQBuffer bodyLocal = message.getBodyBuffer();
bodyLocal.writeBytes(body);
producer.send(message);
if (i % 1000 == 0) {
session.commit();
}
}
session.commit();
}
示例3: encodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void encodeRest(final ActiveMQBuffer buffer) {
buffer.writeLong(fileId);
if (fileId == -1)
return;
buffer.writeByte(fileType.code);
switch (fileType) {
case JOURNAL: {
buffer.writeByte(journalType.typeByte);
break;
}
case PAGE: {
buffer.writeSimpleString(pageStoreName);
break;
}
case LARGE_MESSAGE:
default:
// no-op
}
buffer.writeInt(dataSize);
/*
* sending -1 will close the file in case of a journal, but not in case of a largeMessage
* (which might receive appends)
*/
if (dataSize > 0) {
buffer.writeBytes(byteBuffer, 0, byteBuffer.writerIndex());
}
release();
}
示例4: encode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void encode(final ActiveMQBuffer buffer) {
buffer.writeSimpleString(address);
buffer.writeInt(duplID.length);
buffer.writeBytes(duplID);
}
示例5: createLargeMessage
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private ClientMessage createLargeMessage(ClientSession session, final int largeSize) {
ClientMessage message = session.createMessage(true);
ActiveMQBuffer bodyBuffer = message.getBodyBuffer();
final int propSize = 10240;
while (bodyBuffer.writerIndex() < largeSize) {
byte[] prop = new byte[propSize];
bodyBuffer.writeBytes(prop);
}
return message;
}
示例6: embedAsCoreMessage
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static ICoreMessage embedAsCoreMessage(Message source) {
if (source instanceof ICoreMessage) {
return (ICoreMessage) source;
} else {
Persister persister = source.getPersister();
CoreMessage message = new CoreMessage(source.getMessageID(), persister.getEncodeSize(source) + signature.length + CoreMessage.BODY_OFFSET).setType(Message.EMBEDDED_TYPE);
ActiveMQBuffer buffer = message.getBodyBuffer();
buffer.writeBytes(signature);
persister.encode(buffer, source);
return message;
}
}
示例7: simulateRead
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void simulateRead(ActiveMQBuffer buf) {
buf.setIndex(buf.capacity() / 2, buf.capacity() / 2);
// ok this is not actually happening during the read process, but changing this shouldn't affect the buffer on copy
// this is to exaggerate the isolation on this test
buf.writeBytes(new byte[1024]);
}
示例8: encodeXid
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static void encodeXid(final Xid xid, final ActiveMQBuffer out) {
out.writeInt(xid.getFormatId());
out.writeInt(xid.getBranchQualifier().length);
out.writeBytes(xid.getBranchQualifier());
out.writeInt(xid.getGlobalTransactionId().length);
out.writeBytes(xid.getGlobalTransactionId());
}
示例9: encode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public int encode(final ActiveMQBuffer bufferOut, final int size) throws ActiveMQException {
// This could maybe be optimized (maybe reading directly into bufferOut)
ByteBuffer bufferRead = ByteBuffer.allocate(size);
int bytesRead = encode(bufferRead);
bufferRead.flip();
if (bytesRead > 0) {
bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
}
return bytesRead;
}
示例10: sendHandshake
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
protected void sendHandshake(Connection transportConnection) {
if (transportConnection.isUsingProtocolHandling()) {
// no need to send handshake on inVM as inVM is not using the NettyProtocolHandling
ActiveMQBuffer amqbuffer = connection.createTransportBuffer(handshake.length());
amqbuffer.writeBytes(handshake.getBytes());
transportConnection.write(amqbuffer);
}
}
示例11: encode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void encode(final ActiveMQBuffer buffer) {
buffer.writeBytes(new byte[5]);
}
示例12: persist
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void persist(ActiveMQBuffer targetRecord) {
checkBuffer();
targetRecord.writeInt(internalPersistSize());
targetRecord.writeBytes(data.array(), 0, data.array().length );
}
示例13: toActiveMQBuffer
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static ActiveMQBuffer toActiveMQBuffer(ByteSequence bytes) {
ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(bytes.length);
buffer.writeBytes(bytes.data, bytes.offset, bytes.length);
return buffer;
}
示例14: bytesWriteBytes
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static void bytesWriteBytes(ActiveMQBuffer message, byte[] value) {
message.writeBytes(value);
}
示例15: fillAddress
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void fillAddress() throws Exception {
final int PAGE_MAX = 100 * 1024;
final int PAGE_SIZE = 10 * 1024;
final int MESSAGE_SIZE = 1024; // 1k
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false);
ActiveMQServer server = createServer(true, config, PAGE_SIZE, PAGE_MAX, new HashMap<String, AddressSettings>(), storeType);
server.start();
server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP);
locator = createInVMNonHALocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true);
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
session.createQueue(ADDRESS, ADDRESS, null, true);
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage message;
byte[] body = new byte[MESSAGE_SIZE];
ByteBuffer bb = ByteBuffer.wrap(body);
for (int j = 1; j <= MESSAGE_SIZE; j++) {
bb.put(getSamplebyte(j));
}
for (int i = 0; i < 5000; i++) {
message = session.createMessage(true);
ActiveMQBuffer bodyLocal = message.getBodyBuffer();
bodyLocal.writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
producer.send(message);
if (i % 1000 == 0) {
session.commit();
}
}
session.commit();
session.close();
}