当前位置: 首页>>代码示例>>Java>>正文


Java ActiveMQBuffer.writerIndex方法代码示例

本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.writerIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.writerIndex方法的具体用法?Java ActiveMQBuffer.writerIndex怎么用?Java ActiveMQBuffer.writerIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.artemis.api.core.ActiveMQBuffer的用法示例。


在下文中一共展示了ActiveMQBuffer.writerIndex方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addMessages

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private int addMessages(final int start, final int numMessages, final int messageSize) throws Exception {
   PagingStoreImpl pageStore = lookupPageStore(ADDRESS);

   pageStore.startPaging();

   RoutingContext ctx = generateCTX();

   for (int i = start; i < start + numMessages; i++) {
      if (i % 100 == 0)
         System.out.println("Paged " + i);
      ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);

      Message msg = new CoreMessage(i, buffer.writerIndex());
      msg.putIntProperty("key", i);
      // to be used on tests that are validating filters
      msg.putBooleanProperty("even", i % 2 == 0);

      msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());

      Assert.assertTrue(pageStore.page(msg, ctx.getTransaction(), ctx.getContextListing(ADDRESS), lock));
   }

   return pageStore.getNumberOfPages();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:PageCursorStressTest.java

示例2: pgMessages

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
 * @param storage
 * @param pageStore
 * @param pgParameter
 * @param start
 * @param NUM_MESSAGES
 * @param messageSize
 * @throws Exception
 */
private Transaction pgMessages(StorageManager storage,
                               PagingStoreImpl pageStore,
                               long pgParameter,
                               int start,
                               final int NUM_MESSAGES,
                               final int messageSize) throws Exception {

   TransactionImpl txImpl = new TransactionImpl(pgParameter, null, storage);

   RoutingContext ctx = generateCTX(txImpl);

   for (int i = start; i < start + NUM_MESSAGES; i++) {
      ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
      Message msg = new CoreMessage(storage.generateID(), buffer.writerIndex());
      msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
      msg.putIntProperty("key", i);
      pageStore.page(msg, ctx.getTransaction(), ctx.getContextListing(ADDRESS), lock);
   }

   return txImpl;

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:32,代码来源:PageCursorStressTest.java

示例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);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:13,代码来源:XmlDataExporterUtil.java

示例4: 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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:FailoverWithDivertTest.java

示例5: write

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void write(final ActiveMQBuffer bytes, final boolean sync, final IOCallback callback) throws Exception {
   bytes.writerIndex(bytes.capacity());
   bytes.readerIndex(0);
   writeDirect(bytes.toByteBuffer(), sync, callback);

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:FakeSequentialFileFactory.java

示例6: encodeSize

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
protected void encodeSize(ActiveMQBuffer buffer) {
   size = buffer.writerIndex();

   // The length doesn't include the actual length byte
   int len = size - DataConstants.SIZE_INT;

   buffer.setInt(0, len);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:PacketImpl.java

示例7: getBytes

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void getBytes(final int index, final ActiveMQBuffer dst, final int length) {
   if (length > dst.writableBytes()) {
      throw new IndexOutOfBoundsException();
   }
   getBytes(index, dst, dst.writerIndex(), length);
   dst.writerIndex(dst.writerIndex() + length);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:CompressedLargeMessageControllerImpl.java

示例8: readBytes

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void readBytes(final ActiveMQBuffer dst, final int length) {
   if (length > dst.writableBytes()) {
      throw new IndexOutOfBoundsException();
   }
   readBytes(dst, dst.writerIndex(), length);
   dst.writerIndex(dst.writerIndex() + length);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:CompressedLargeMessageControllerImpl.java

示例9: handleCompressedMessage

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
 * This method deals with messages arrived as regular message but its contents are compressed.
 * Such messages come from message senders who are configured to compress large messages, and
 * if some of the messages are compressed below the min-large-message-size limit, they are sent
 * as regular messages.
 * <br>
 * However when decompressing the message, we are not sure how large the message could be..
 * for that reason we fake a large message controller that will deal with the message as it was a large message
 * <br>
 * Say that you sent a 1G message full of spaces. That could be just bellow 100K compressed but you wouldn't have
 * enough memory to decompress it
 */
private void handleCompressedMessage(final ClientMessageInternal clMessage) throws Exception {
   ClientLargeMessageImpl largeMessage = new ClientLargeMessageImpl();
   largeMessage.retrieveExistingData(clMessage);

   File largeMessageCache = null;

   if (session.isCacheLargeMessageClient()) {
      largeMessageCache = File.createTempFile("tmp-large-message-" + largeMessage.getMessageID() + "-", ".tmp");
      largeMessageCache.deleteOnExit();
   }

   ClientSessionFactory sf = session.getSessionFactory();
   ServerLocator locator = sf.getServerLocator();
   long callTimeout = locator.getCallTimeout();

   currentLargeMessageController = new LargeMessageControllerImpl(this, largeMessage.getLargeMessageSize(), callTimeout, largeMessageCache);
   currentLargeMessageController.setLocal(true);

   //sets the packet
   ActiveMQBuffer qbuff = clMessage.toCore().getBodyBuffer();
   int bytesToRead = qbuff.writerIndex() - qbuff.readerIndex();
   final byte[] body = ByteUtil.getActiveArray(qbuff.readBytes(bytesToRead).toByteBuffer());

   largeMessage.setLargeMessageController(new CompressedLargeMessageControllerImpl(currentLargeMessageController));
   currentLargeMessageController.addPacket(body, body.length, false);

   handleRegularMessage(largeMessage);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:41,代码来源:ClientConsumerImpl.java

示例10: createMessageFrame

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public StompFrame createMessageFrame(ICoreMessage serverMessage,
                                     ActiveMQBuffer bodyBuffer,
                                     StompSubscription subscription,
                                     int deliveryCount) throws Exception {
   StompFrame frame = createStompFrame(Stomp.Responses.MESSAGE);

   if (subscription.getID() != null) {
      frame.addHeader(Stomp.Headers.Message.SUBSCRIPTION, subscription.getID());
   }

   ActiveMQBuffer buffer = bodyBuffer != null ? bodyBuffer : serverMessage.getReadOnlyBodyBuffer();

   int size = buffer.writerIndex();

   byte[] data = new byte[size];

   if (serverMessage.containsProperty(Stomp.Headers.CONTENT_LENGTH) || serverMessage.getType() == Message.BYTES_TYPE) {
      frame.addHeader(Headers.CONTENT_LENGTH, String.valueOf(data.length));
      buffer.readBytes(data);
   } else {
      SimpleString text = buffer.readNullableSimpleString();
      if (text != null) {
         data = text.toString().getBytes(StandardCharsets.UTF_8);
      } else {
         data = new byte[0];
      }
   }
   frame.setByteBody(data);

   StompUtils.copyStandardHeadersFromMessageToFrame((serverMessage), frame, deliveryCount);

   return frame;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:VersionedStompFrameHandler.java

示例11: readActiveMQBuffer

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private ActiveMQBuffer readActiveMQBuffer(SequentialFile file, int size) throws Exception {
   ByteBuffer byteBuffer = ByteBuffer.allocate(size);
   byteBuffer.mark();
   file.read(byteBuffer);
   byteBuffer.reset();

   ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(byteBuffer);
   buffer.writerIndex(size);
   return buffer;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:PagingStoreFactoryDatabase.java

示例12: encode

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void encode(ActiveMQBuffer buffer) {
   final int writerIndex = buffer.writerIndex();
   buffer.setBytes(writerIndex, msgContent);
   buffer.writerIndex(writerIndex + msgSize);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:7,代码来源:JournalTptBenchmark.java

示例13: sendBadData

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private static void sendBadData(BroadcastEndpointFactory factoryEndpoint) throws Exception {
   BroadcastEndpoint endpoint = factoryEndpoint.createBroadcastEndpoint();

   ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(500);

   buffer.writeString("This is a test1!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
   buffer.writeString("This is a test2!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

   byte[] bytes = new byte[buffer.writerIndex()];

   buffer.readBytes(bytes);

   // messing up with the string!!!
   for (int i = bytes.length - 10; i < bytes.length; i++) {
      bytes[i] = 0;
   }

   endpoint.openBroadcaster();

   endpoint.broadcast(bytes);

   endpoint.close(true);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:DiscoveryStayAliveTest.java


注:本文中的org.apache.activemq.artemis.api.core.ActiveMQBuffer.writerIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。