private Map<String, Object> buildQueueArgumentMap(String queueName, String owner, boolean exclusive, FieldTable arguments) { Map<String, Object> attributesMap = new HashMap<String, Object>(); attributesMap.put(Queue.NAME, queueName); attributesMap.put(Queue.EXCLUSIVE, exclusive); HashMap<String, Object> argumentsCopy = new HashMap<>(); if (arguments != null) { argumentsCopy.putAll(FieldTable.convertToMap(arguments)); } if (moveNonExclusiveOwnerToDescription(owner, exclusive)) { LOGGER.info("Non-exclusive owner " + owner + " for queue " + queueName + " moved to " + QueueArgumentsConverter.X_QPID_DESCRIPTION); attributesMap.put(Queue.OWNER, null); argumentsCopy.put(QueueArgumentsConverter.X_QPID_DESCRIPTION, owner); } else { attributesMap.put(Queue.OWNER, owner); } if (!argumentsCopy.isEmpty()) { attributesMap.put(ARGUMENTS, argumentsCopy); } return attributesMap; }
public synchronized void writeToBuffer(QpidByteBuffer buffer) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("FieldTable::writeToBuffer: Writing encoded length of " + getEncodedSize() + "..."); if (_decoded) { LOGGER.debug(getProperties().toString()); } } buffer.putUnsignedInt(getEncodedSize()); putDataInBuffer(buffer); }
public static FieldTable createFieldTable(final Map<String, Object> map) { return new FieldTable(map); } }
public Object get(String key) { checkPropertyName(key); AMQTypedValue value = getProperty(key); if (value != null && value != NOT_PRESENT) { return value.getValue(); } else { return null; } }
public static Map<String, Object> convertToMap(final FieldTable fieldTable) { final Map<String, Object> map = new HashMap<>(); if (fieldTable != null) { Map<String, AMQTypedValue> properties = fieldTable.getProperties(); if (properties != null) { for (Map.Entry<String, AMQTypedValue> e : properties.entrySet()) { Object val = e.getValue().getValue(); if (val instanceof AMQShortString) { val = val.toString(); } else if (val instanceof FieldTable) { val = FieldTable.convertToMap((FieldTable) val); } map.put(e.getKey(), val); } } } return map; }
public final QueueDeclareBody createQueueDeclareBody(final int ticket, final String queue, final boolean passive, final boolean durable, final boolean exclusive, final boolean autoDelete, final boolean nowait, final Map<String,Object> arguments) { return new QueueDeclareBody(ticket, AMQShortString.valueOf(queue), passive, durable, exclusive, autoDelete, nowait, FieldTable.convertToFieldTable(arguments)); }
EnumSet<ConsumerOption> options = EnumSet.noneOf(ConsumerOption.class); final boolean multiQueue = sources.size()>1; if(arguments != null && Boolean.TRUE.equals(arguments.get(AMQPFilterTypes.NO_CONSUME.getValue()))) FilterManager filterManager = FilterManagerFactory.createManager(FieldTable.convertToMap(arguments)); if(noLocal) if(arguments != null && arguments.containsKey(AMQPFilterTypes.REPLAY_PERIOD.toString())) Object value = arguments.get(AMQPFilterTypes.REPLAY_PERIOD.toString()); final long period; if(value instanceof Number) if(arguments != null && arguments.containsKey("x-priority")) Object value = arguments.get("x-priority"); if(value instanceof Number)
public static void writeFieldTable(FieldTable fieldTable, TupleOutput tupleOutput) { if (fieldTable == null) { tupleOutput.writeLong(0); } else { tupleOutput.writeLong(fieldTable.getEncodedSize()); tupleOutput.writeFast(fieldTable.getDataAsBytes()); } } }
public synchronized byte[] getDataAsBytes() { if (_encodedForm == null) { byte[] data = new byte[(int) getEncodedSize()]; QpidByteBuffer buf = QpidByteBuffer.wrap(data); putDataInBuffer(buf); return data; } else { byte[] encodedCopy = new byte[_encodedForm.remaining()]; _encodedForm.copyTo(encodedCopy); return encodedCopy; } }
synchronized void reallocate() { _headers.clearEncodedForm(); if (_encodedForm != null) { _encodedForm = QpidByteBuffer.reallocateIfNecessary(_encodedForm); } }
public static int encodedFieldTableLength(FieldTable table) { if (table == null) { // length is encoded as 4 octets return 4; } else { // length of the table plus 4 octets for the length return (int) table.getEncodedSize() + 4; } }
FieldTable(Map<String, Object> properties, boolean strictAMQP) { _strictAMQP = strictAMQP; long size = 0; Map<String, AMQTypedValue> m = new LinkedHashMap<>(); if (properties != null && !properties.isEmpty()) { m = new LinkedHashMap<>(); for (Map.Entry<String, Object> e : properties.entrySet()) { String key = e.getKey(); Object val = e.getValue(); checkPropertyName(key); AMQTypedValue value = getAMQTypeValue(val); size += EncodingUtils.encodedShortStringLength(e.getKey()) + 1 + value.getEncodingSize(); m.put(e.getKey(), value); } } _properties = m; _encodedSize = size; _decoded = true; }
private void checkPropertyName(String propertyName) { if (propertyName == null) { throw new IllegalArgumentException("Property name must not be null"); } else if (propertyName.length() == 0) { throw new IllegalArgumentException("Property name must not be the empty string"); } if (_strictAMQP) { checkIdentiferFormat(propertyName); } }
private void decode() { if (_encodedSize > 0 && _encodedForm != null) { if (!_properties.isEmpty()) { _properties.clear(); } _encodedForm.mark(); try { do { final String key = AMQShortString.readAMQShortStringAsString(_encodedForm); checkPropertyName(key); AMQTypedValue value = AMQTypedValue.readFromBuffer(_encodedForm); _properties.put(key, value); } while (_encodedForm.hasRemaining()); } finally { _encodedForm.reset(); } } }
public final BasicConsumeBody createBasicConsumeBody(final int ticket, final String queue, final String consumerTag, final boolean noLocal, final boolean noAck, final boolean exclusive, final boolean nowait, final Map<String,Object> arguments) { return new BasicConsumeBody(ticket, AMQShortString.valueOf(queue), AMQShortString.valueOf(consumerTag), noLocal, noAck, exclusive, nowait, FieldTable.convertToFieldTable(arguments)); }
public synchronized void clearEncodedForm() { nullEncodedForm(); _headers.clearEncodedForm(); }
private UpgradeConfiguredObjectRecord createBindingConfiguredObjectRecord(String exchangeName, String queueName, String routingKey, FieldTable arguments, String virtualHostName) { Map<String, Object> attributesMap = new HashMap<String, Object>(); attributesMap.put("name", routingKey); attributesMap.put("exchange", UUIDGenerator.generateExchangeUUID(exchangeName, virtualHostName)); attributesMap.put("queue", UUIDGenerator.generateQueueUUID(queueName, virtualHostName)); if (arguments != null) { attributesMap.put("arguments", FieldTable.convertToMap(arguments)); } String json = serialiseMap(attributesMap); UpgradeConfiguredObjectRecord configuredObject = new UpgradeConfiguredObjectRecord(Binding.class.getName(), json); return configuredObject; }
public final ExchangeDeclareBody createExchangeDeclareBody(final int ticket, final String exchange, final String type, final boolean passive, final boolean durable, final boolean autoDelete, final boolean internal, final boolean nowait, final Map<String,Object> arguments) { return new ExchangeDeclareBody(ticket, AMQShortString.valueOf(exchange), AMQShortString.valueOf(type), passive, durable, autoDelete, internal, nowait, FieldTable.convertToFieldTable(arguments)); }
public static void process(final QpidByteBuffer buffer, final ClientChannelMethodProcessor dispatcher) throws AMQFrameDecodingException { int replyCode = buffer.getUnsignedShort(); AMQShortString replyText = AMQShortString.readAMQShortString(buffer); FieldTable details = EncodingUtils.readFieldTable(buffer); if(!dispatcher.ignoreAllButCloseOk()) { dispatcher.receiveChannelAlert(replyCode, replyText, details); } if (details != null) { details.clearEncodedForm(); } } }
public static FieldTable createFieldTable(QpidByteBuffer fieldTableBuffer) { return new FieldTable(fieldTableBuffer); }