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


Java ActiveMQBuffer.readableBytes方法代码示例

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


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

示例1: sendInternalLarge

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public void sendInternalLarge(CoreMessage message, boolean direct) throws Exception {
   int headerSize = message.getHeadersAndPropertiesEncodeSize();
   if (headerSize >= connection.getMinLargeMessageSize()) {
      throw BUNDLE.headerTooBig();
   }

   StorageManager storageManager = ((ServerSessionImpl) session).getStorageManager();
   long id = storageManager.generateID();
   LargeServerMessage largeMessage = storageManager.createLargeMessage(id, message);

   ActiveMQBuffer body = message.getReadOnlyBodyBuffer();
   byte[] bytes = new byte[body.readableBytes()];
   body.readBytes(bytes);

   largeMessage.addBytes(bytes);

   largeMessage.releaseResources();

   largeMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, bytes.length);

   session.send(largeMessage, direct);

   largeMessage = null;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:StompSession.java

示例2: extractEmbedded

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static Message extractEmbedded(ICoreMessage message) {
   if (message.getType() == Message.EMBEDDED_TYPE) {
      ActiveMQBuffer buffer = message.getReadOnlyBodyBuffer();

      if (buffer.readableBytes() < signature.length || !checkSignature(buffer)) {
         if (!logger.isTraceEnabled()) {
            logger.trace("Message type " + Message.EMBEDDED_TYPE + " was used for something other than embed messages, ignoring content and treating as a regular message");
         }
         return message;
      }

      try {
         return MessagePersister.getInstance().decode(buffer, null);
      } catch (Exception e) {
         logger.warn(e.getMessage(), e);
         return message;
      }
   } else {
      return message;
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:EmbedMessageUtil.java

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

示例4: addBytes

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public void addBytes(final ActiveMQBuffer bytes, final boolean sync, final IOCallback callback) {
   enterCritical(CRITICAL_PATH_ADD_BYTES);
   try {
      synchronized (this) {
         if (!started) {
            throw new IllegalStateException("TimedBuffer is not started");
         }

         delayFlush = false;

         //it doesn't modify the reader index of bytes as in the original version
         final int readableBytes = bytes.readableBytes();
         final int writerIndex = buffer.writerIndex();
         buffer.setBytes(writerIndex, bytes, bytes.readerIndex(), readableBytes);
         buffer.writerIndex(writerIndex + readableBytes);

         callbacks.add(callback);

         if (sync) {
            pendingSync = true;

            startSpin();
         }
      }
   } finally {
      leaveCritical(CRITICAL_PATH_ADD_BYTES);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:29,代码来源:TimedBuffer.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 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);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:AbstractSequentialFile.java

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

示例7: write

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public final void write(ActiveMQBuffer buffer,
                        final boolean flush,
                        final boolean batched,
                        final ChannelFutureListener futureListener) {
   final int readableBytes = buffer.readableBytes();
   if (logger.isDebugEnabled()) {
      final int remainingBytes = this.writeBufferHighWaterMark - readableBytes;
      if (remainingBytes < 0) {
         logger.debug("a write request is exceeding by " + (-remainingBytes) + " bytes the writeBufferHighWaterMark size [ " + this.writeBufferHighWaterMark + " ] : consider to set it at least of " + readableBytes + " bytes");
      }
   }
   //no need to lock because the Netty's channel is thread-safe
   //and the order of write is ensured by the order of the write calls
   final EventLoop eventLoop = channel.eventLoop();
   final boolean inEventLoop = eventLoop.inEventLoop();
   if (!inEventLoop) {
      writeNotInEventLoop(buffer, flush, batched, futureListener);
   } else {
      // OLD COMMENT:
      // create a task which will be picked up by the eventloop and trigger the write.
      // This is mainly needed as this method is triggered by different threads for the same channel.
      // if we not do this we may produce out of order writes.
      // NOTE:
      // the submitted task does not effect in any way the current written size in the batch
      // until the loop will process it, leading to a longer life for the ActiveMQBuffer buffer!!!
      // To solve it, will be necessary to manually perform the count of the current batch instead of rely on the
      // Channel:Config::writeBufferHighWaterMark value.
      this.pendingWritesOnEventLoop += readableBytes;
      this.pendingWritesOnEventLoopView.lazySet(pendingWritesOnEventLoop);
      eventLoop.execute(() -> {
         this.pendingWritesOnEventLoop -= readableBytes;
         this.pendingWritesOnEventLoopView.lazySet(pendingWritesOnEventLoop);
         writeInEventLoop(buffer, flush, batched, futureListener);
      });
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:38,代码来源:NettyConnection.java

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

示例9: decodeRest

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
   messageId = buffer.readLong();
   if (buffer.readableBytes() >= DataConstants.SIZE_LONG) {
      pendingRecordId = buffer.readLong();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:ReplicationLargeMessageEndMessage.java

示例10: decode

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decode(final ActiveMQBuffer buffer) {
   name = buffer.readSimpleString();
   address = buffer.readSimpleString();
   filterString = buffer.readNullableSimpleString();

   String metadata = buffer.readNullableSimpleString().toString();
   if (metadata != null) {
      String[] elements = metadata.split(";");
      for (String element : elements) {
         String[] keyValuePair = element.split("=");
         if (keyValuePair.length == 2) {
            if (keyValuePair[0].equals("user")) {
               user = SimpleString.toSimpleString(keyValuePair[1]);
            }
         }
      }
   }

   autoCreated = buffer.readBoolean();

   if (buffer.readableBytes() > 0) {
      maxConsumers = buffer.readInt();
      purgeOnNoConsumers = buffer.readBoolean();
      routingType = buffer.readByte();
   } else {
      maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
      purgeOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers();
      routingType = ActiveMQDefaultConfiguration.getDefaultRoutingType().getType();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:32,代码来源:PersistentQueueBindingEncoding.java

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

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

示例13: reloadStores

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public synchronized List<PagingStore> reloadStores(final HierarchicalRepository<AddressSettings> addressSettingsRepository) throws Exception {
   // We assume the directory list < Integer.MAX_VALUE (this is only a list of addresses).
   JDBCSequentialFile directoryList = (JDBCSequentialFile) pagingFactoryFileFactory.createSequentialFile(DIRECTORY_NAME);
   directoryList.open();

   int size = ((Long) directoryList.size()).intValue();
   ActiveMQBuffer buffer = readActiveMQBuffer(directoryList, size);

   ArrayList<PagingStore> storesReturn = new ArrayList<>();

   while (buffer.readableBytes() > 0) {
      SimpleString table = buffer.readSimpleString();

      JDBCSequentialFileFactory factory = (JDBCSequentialFileFactory) newFileFactory(table.toString(), false);
      factory.start();

      JDBCSequentialFile addressFile = (JDBCSequentialFile) factory.createSequentialFile(ADDRESS_FILE);
      addressFile.open();

      size = ((Long) addressFile.size()).intValue();
      if (size == 0) {
         continue;
      }

      ActiveMQBuffer addrBuffer = readActiveMQBuffer(addressFile, size);
      SimpleString address = addrBuffer.readSimpleString();

      AddressSettings settings = addressSettingsRepository.getMatch(address.toString());

      PagingStore store = new PagingStoreImpl(address, scheduledExecutor, syncTimeout, pagingManager, storageManager, factory, this, address, settings, executorFactory.getExecutor(), syncNonTransactional);

      storesReturn.add(store);
   }
   directoryList.close();
   return storesReturn;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:38,代码来源:PagingStoreFactoryDatabase.java

示例14: internalWrite

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public synchronized int internalWrite(ActiveMQBuffer buffer, IOCallback callback) {
   byte[] data = new byte[buffer.readableBytes()];
   buffer.readBytes(data);
   return internalWrite(data, callback);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:6,代码来源:JDBCSequentialFile.java

示例15: decode

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decode(ActiveMQBuffer buffer) {
   data = new byte[buffer.readableBytes()];
   buffer.readBytes(data);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:6,代码来源:FakeEncodingSupportImpl.java


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