Java Code Examples for org.apache.activemq.artemis.api.core.SimpleString#sizeofNullableString()

The following examples show how to use org.apache.activemq.artemis.api.core.SimpleString#sizeofNullableString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentQueueBindingEncoding.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public int getEncodeSize() {
   return SimpleString.sizeofString(name) + SimpleString.sizeofString(address) +
      SimpleString.sizeofNullableString(filterString) + DataConstants.SIZE_BOOLEAN +
      SimpleString.sizeofNullableString(createMetadata()) +
      DataConstants.SIZE_INT +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BYTE +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_INT +
      DataConstants.SIZE_LONG +
      SimpleString.sizeofNullableString(lastValueKey) +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_INT +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_LONG +
      DataConstants.SIZE_LONG +
      SimpleString.sizeofNullableString(groupFirstKey) +
      DataConstants.SIZE_LONG +
      DataConstants.SIZE_BOOLEAN;
}
 
Example 2
Source File: XMLMessageImporter.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Message bodies are written to XML as one or more Base64 encoded CDATA elements. Some parser implementations won't
 * read an entire CDATA element at once (e.g. Woodstox) so it's possible that multiple CDATA/CHARACTERS events need
 * to be combined to reconstruct the Base64 encoded string.  You can't decode bits and pieces of each CDATA.  Each
 * CDATA has to be decoded in its entirety.
 *
 * @param processor used to deal with the decoded CDATA elements
 * @param decodeTextMessage If this a text message we decode UTF8 and encode as a simple string
 */
private void getMessageBodyBytes(MessageBodyBytesProcessor processor, boolean decodeTextMessage) throws IOException, XMLStreamException {
   int currentEventType;
   StringBuilder cdata = new StringBuilder();
   while (reader.hasNext()) {
      currentEventType = reader.getEventType();
      if (currentEventType == XMLStreamConstants.END_ELEMENT) {
         break;
      } else if (currentEventType == XMLStreamConstants.CHARACTERS && reader.isWhiteSpace() && cdata.length() > 0) {
         /* when we hit a whitespace CHARACTERS event we know that the entire CDATA is complete so decode, pass back to
          * the processor, and reset the cdata for the next event(s)
          */
         if (decodeTextMessage) {
            SimpleString text = new SimpleString(cdata.toString());
            ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(SimpleString.sizeofNullableString(text));
            SimpleString.writeNullableSimpleString(byteBuf, text);
            byte[] bytes = new byte[SimpleString.sizeofNullableString(text)];
            byteBuf.readBytes(bytes);
            processor.processBodyBytes(bytes);
         } else {
            processor.processBodyBytes(decode(cdata.toString()));
            cdata.setLength(0);
         }
      } else {
         cdata.append(new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()).trim());
      }
      reader.next();
   }
}
 
Example 3
Source File: CoreMessage.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int getHeadersAndPropertiesEncodeSize() {
   return DataConstants.SIZE_LONG + // Message ID
      DataConstants.SIZE_BYTE + // user id null?
      (userID == null ? 0 : 16) +
          /* address */SimpleString.sizeofNullableString(address) +
      DataConstants./* Type */SIZE_BYTE +
      DataConstants./* Durable */SIZE_BOOLEAN +
      DataConstants./* Expiration */SIZE_LONG +
      DataConstants./* Timestamp */SIZE_LONG +
      DataConstants./* Priority */SIZE_BYTE +
          /* PropertySize and Properties */getProperties().getEncodeSize();
}
 
Example 4
Source File: AMQPLargeMessagePersister.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int getEncodeSize(Message record) {
   AMQPLargeMessage msgEncode = (AMQPLargeMessage) record;
   ByteBuf buf = msgEncode.getSavedEncodeBuffer();

   try {
      int encodeSize = DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + DataConstants.SIZE_LONG + DataConstants.SIZE_LONG + SimpleString.sizeofNullableString(record.getAddressSimpleString()) + DataConstants.SIZE_BOOLEAN + buf.writerIndex();

      TypedProperties properties = ((AMQPMessage) record).getExtraProperties();

      return encodeSize + (properties != null ? properties.getEncodeSize() : 0);
   } finally {
      msgEncode.releaseEncodedBuffer();
   }
}
 
Example 5
Source File: PersistedRoles.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int getEncodeSize() {
   return addressMatch.sizeof() + SimpleString.sizeofNullableString(sendRoles) +
      SimpleString.sizeofNullableString(consumeRoles) +
      SimpleString.sizeofNullableString(createDurableQueueRoles) +
      SimpleString.sizeofNullableString(deleteDurableQueueRoles) +
      SimpleString.sizeofNullableString(createNonDurableQueueRoles) +
      SimpleString.sizeofNullableString(deleteNonDurableQueueRoles) +
      SimpleString.sizeofNullableString(manageRoles) +
      SimpleString.sizeofNullableString(browseRoles) +
      SimpleString.sizeofNullableString(createAddressRoles) +
      SimpleString.sizeofNullableString(deleteAddressRoles);
}
 
Example 6
Source File: ResourceLimitSettings.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int getEncodeSize() {
   return SimpleString.sizeofNullableString(match) +
      BufferHelper.sizeOfNullableInteger(maxConnections) +
      BufferHelper.sizeOfNullableInteger(maxQueues);
   //              BufferHelper.sizeOfNullableLong(maxQueueSizeBytes) +
   //              SimpleString.sizeofNullableString(queueNameRegex);
}
 
Example 7
Source File: CoreMessagePersister.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public int getEncodeSize(Message record) {
   return DataConstants.SIZE_BYTE + record.getPersistSize() +
      SimpleString.sizeofNullableString(record.getAddressSimpleString()) + DataConstants.SIZE_LONG;
}
 
Example 8
Source File: AMQPMessagePersister.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public int getEncodeSize(Message record) {
   return DataConstants.SIZE_BYTE + record.getPersistSize() +
      SimpleString.sizeofNullableString(record.getAddressSimpleString()) + DataConstants.SIZE_LONG + DataConstants.SIZE_LONG;
}
 
Example 9
Source File: AddressSettings.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public int getEncodeSize() {

   return BufferHelper.sizeOfNullableSimpleString(addressFullMessagePolicy != null ? addressFullMessagePolicy.toString() : null) +
      BufferHelper.sizeOfNullableLong(maxSizeBytes) +
      BufferHelper.sizeOfNullableLong(pageSizeBytes == null ? null : Long.valueOf(pageSizeBytes)) +
      BufferHelper.sizeOfNullableInteger(pageMaxCache) +
      BufferHelper.sizeOfNullableBoolean(dropMessagesWhenFull) +
      BufferHelper.sizeOfNullableInteger(maxDeliveryAttempts) +
      BufferHelper.sizeOfNullableInteger(messageCounterHistoryDayLimit) +
      BufferHelper.sizeOfNullableLong(redeliveryDelay) +
      BufferHelper.sizeOfNullableDouble(redeliveryMultiplier) +
      BufferHelper.sizeOfNullableDouble(redeliveryCollisionAvoidanceFactor) +
      BufferHelper.sizeOfNullableLong(maxRedeliveryDelay) +
      SimpleString.sizeofNullableString(deadLetterAddress) +
      SimpleString.sizeofNullableString(expiryAddress) +
      BufferHelper.sizeOfNullableLong(expiryDelay) +
      BufferHelper.sizeOfNullableLong(minExpiryDelay) +
      BufferHelper.sizeOfNullableLong(maxExpiryDelay) +
      BufferHelper.sizeOfNullableBoolean(defaultLastValueQueue) +
      BufferHelper.sizeOfNullableLong(redistributionDelay) +
      BufferHelper.sizeOfNullableBoolean(sendToDLAOnNoRoute) +
      BufferHelper.sizeOfNullableLong(slowConsumerCheckPeriod) +
      BufferHelper.sizeOfNullableLong(slowConsumerThreshold) +
      BufferHelper.sizeOfNullableSimpleString(slowConsumerPolicy != null ? slowConsumerPolicy.toString() : null) +
      BufferHelper.sizeOfNullableBoolean(autoCreateJmsQueues) +
      BufferHelper.sizeOfNullableBoolean(autoDeleteJmsQueues) +
      BufferHelper.sizeOfNullableBoolean(autoCreateJmsTopics) +
      BufferHelper.sizeOfNullableBoolean(autoDeleteJmsTopics) +
      BufferHelper.sizeOfNullableBoolean(autoCreateQueues) +
      BufferHelper.sizeOfNullableBoolean(autoDeleteQueues) + BufferHelper.sizeOfNullableSimpleString(configDeleteQueues != null ? configDeleteQueues.toString() : null) +
      BufferHelper.sizeOfNullableBoolean(autoCreateAddresses) +
      BufferHelper.sizeOfNullableBoolean(autoDeleteAddresses) + BufferHelper.sizeOfNullableSimpleString(configDeleteAddresses != null ? configDeleteAddresses.toString() : null) +
      BufferHelper.sizeOfNullableInteger(managementBrowsePageSize) +
      BufferHelper.sizeOfNullableLong(maxSizeBytesRejectThreshold) +
      BufferHelper.sizeOfNullableInteger(defaultMaxConsumers) +
      BufferHelper.sizeOfNullableBoolean(defaultPurgeOnNoConsumers) +
      DataConstants.SIZE_BYTE +
      DataConstants.SIZE_BYTE +
      BufferHelper.sizeOfNullableBoolean(defaultExclusiveQueue) +
      BufferHelper.sizeOfNullableInteger(defaultConsumersBeforeDispatch) +
      BufferHelper.sizeOfNullableLong(defaultDelayBeforeDispatch) +
      BufferHelper.sizeOfNullableInteger(defaultConsumerWindowSize) +
      SimpleString.sizeofNullableString(defaultLastValueKey) +
      BufferHelper.sizeOfNullableBoolean(defaultNonDestructive) +
      BufferHelper.sizeOfNullableLong(autoDeleteQueuesDelay) +
      BufferHelper.sizeOfNullableLong(autoDeleteAddressesDelay) +
      BufferHelper.sizeOfNullableBoolean(defaultGroupRebalance) +
      BufferHelper.sizeOfNullableInteger(defaultGroupBuckets) +
      SimpleString.sizeofNullableString(defaultGroupFirstKey) +
      BufferHelper.sizeOfNullableLong(autoDeleteQueuesMessageCount) +
      BufferHelper.sizeOfNullableBoolean(autoDeleteCreatedQueues) +
      BufferHelper.sizeOfNullableLong(defaultRingSize) +
      BufferHelper.sizeOfNullableLong(retroactiveMessageCount) +
      BufferHelper.sizeOfNullableBoolean(autoCreateDeadLetterResources) +
      SimpleString.sizeofNullableString(deadLetterQueuePrefix) +
      SimpleString.sizeofNullableString(deadLetterQueueSuffix) +
      BufferHelper.sizeOfNullableBoolean(autoCreateExpiryResources) +
      SimpleString.sizeofNullableString(expiryQueuePrefix) +
      SimpleString.sizeofNullableString(expiryQueueSuffix) +
      BufferHelper.sizeOfNullableBoolean(enableMetrics);
}