private AMQBody createEncodedDeliverBody(AMQMessage message, boolean isRedelivered, final long deliveryTag, final AMQShortString consumerTag) { final AMQShortString exchangeName; final AMQShortString routingKey; final MessagePublishInfo pb = message.getMessagePublishInfo(); exchangeName = pb.getExchange(); routingKey = pb.getRoutingKey(); return new EncodedDeliveryBody(deliveryTag, routingKey, exchangeName, consumerTag, isRedelivered); }
@Override public void writeToBuffer(final QpidByteBuffer dest) { dest.putInt(_contentHeaderBody.getSize()); _contentHeaderBody.writePayload(dest); EncodingUtils.writeShortStringBytes(dest, _messagePublishInfo.getExchange()); EncodingUtils.writeShortStringBytes(dest, _messagePublishInfo.getRoutingKey()); byte flags = 0; if(_messagePublishInfo.isMandatory()) { flags |= MANDATORY_FLAG; } if(_messagePublishInfo.isImmediate()) { flags |= IMMEDIATE_FLAG; } dest.put(flags); dest.putLong(_arrivalTime); }
private MessagePublishInfo readMessagePublishInfo(TupleInput tupleInput) { final AMQShortString exchange = AMQShortStringEncoding.readShortString(tupleInput); final AMQShortString routingKey = AMQShortStringEncoding.readShortString(tupleInput); final boolean mandatory = tupleInput.readBoolean(); final boolean immediate = tupleInput.readBoolean(); return new MessagePublishInfo(exchange, immediate, mandatory, routingKey); }
String routingKey = AMQShortString.toString(info.getRoutingKey()); String exchangeName = AMQShortString.toString(info.getExchange()); _connection.checkAuthorizedMessagePrincipal(AMQShortString.toString(contentHeader.getProperties().getUserId())); _publishAuthCache.authorisePublish(destination, routingKey, info.isImmediate(), _connection.getLastReadTime());
public AMQShortString getExchangeName() { return _messagePublishInfo.getExchange(); }
@Override public String getInitialRoutingAddress() { MessageMetaData messageMetaData = getMessageMetaData(); AMQShortString routingKey = messageMetaData.getMessagePublishInfo().getRoutingKey(); if (routingKey != null) { return routingKey.toString(); } return ""; }
public boolean isImmediate() { return getMessagePublishInfo().isImmediate(); }
public boolean isMandatory() { return getMessagePublishInfo().isMandatory(); }
return new MessagePublishInfo(convertToShortStringForProperty("to", exchangeName), false, false,
@Override public String getTo() { return AMQShortString.toString(getMessagePublishInfo().getExchange()); }
private AMQBody createEncodedReturnFrame(MessagePublishInfo messagePublishInfo, int replyCode, AMQShortString replyText) { return _connection.getMethodRegistry().createBasicReturnBody(replyCode, replyText, messagePublishInfo.getExchange(), messagePublishInfo.getRoutingKey()); }
@Override public QpidByteBuffer convertToMessageFormat(final AMQMessage message) { final MessagePublishInfo messagePublishInfo = message.getMessagePublishInfo(); final ContentHeaderBody contentHeaderBody = message.getContentHeaderBody(); AMQShortString exchange = messagePublishInfo.getExchange(); AMQShortString routingKey = messagePublishInfo.getRoutingKey(); int length = contentHeaderBody.getSize() + (exchange == null ? 0 : exchange.length()) + (routingKey == null ? 0 : routingKey.length()) + 3; try (QpidByteBuffer headerBuf = QpidByteBuffer.allocateDirect(length); QpidByteBuffer content = message.getContent()) { EncodingUtils.writeShortStringBytes(headerBuf, exchange); EncodingUtils.writeShortStringBytes(headerBuf, routingKey); byte flags = messagePublishInfo.isMandatory() ? (byte) 0 : MANDATORY_MASK; if (messagePublishInfo.isImmediate()) { flags |= IMMEDIATE_MASK; } headerBuf.put(flags); headerBuf.flip(); contentHeaderBody.writePayload(headerBuf); return QpidByteBuffer.concatenate(headerBuf, content); } }
return new MessagePublishInfo(convertToShortStringForProperty("to", exchangeName), false, false,
@Override public int getStorableSize() { int size = _contentHeaderBody.getSize(); size += 4; size += EncodingUtils.encodedShortStringLength(_messagePublishInfo.getExchange()); size += EncodingUtils.encodedShortStringLength(_messagePublishInfo.getRoutingKey()); size += 1; // flags for immediate/mandatory size += EncodingUtils.encodedLongLength(); return size; }
@Override public MessageMetaData createMetaData(QpidByteBuffer buf) { try { final int size = buf.getInt(); ContentHeaderBody chb = ContentHeaderBody.createFromBuffer(buf, size); final AMQShortString exchange = AMQShortString.readAMQShortString(buf); final AMQShortString routingKey = AMQShortString.readAMQShortString(buf); final byte flags = buf.get(); long arrivalTime = buf.getLong(); MessagePublishInfo publishBody = new MessagePublishInfo(exchange, (flags & IMMEDIATE_FLAG) != 0, (flags & MANDATORY_FLAG) != 0, routingKey); return new MessageMetaData(publishBody, chb, arrivalTime); } catch (AMQFrameDecodingException | AMQProtocolVersionException e) { throw new ConnectionScopedRuntimeException(e); } } }
private AMQBody createEncodedGetOkBody(AMQMessage message, InstanceProperties props, long deliveryTag, int queueSize) { final AMQShortString exchangeName; final AMQShortString routingKey; final MessagePublishInfo pb = message.getMessagePublishInfo(); exchangeName = pb.getExchange(); routingKey = pb.getRoutingKey(); final boolean isRedelivered = Boolean.TRUE.equals(props.getProperty(InstanceProperties.Property.REDELIVERED)); return _connection.getMethodRegistry().createBasicGetOkBody(deliveryTag, isRedelivered, exchangeName, routingKey, queueSize); }
@Override public AMQMessage createMessage(final QpidByteBuffer payload, final MessageStore store, final Object connectionReference) { try { AMQShortString exchange = readShortString(payload); AMQShortString routingKey = readShortString(payload); byte flags = payload.get(); final MessagePublishInfo publishBody = new MessagePublishInfo(exchange, (flags & IMMEDIATE_MASK) != 0, (flags & MANDATORY_MASK) != 0, routingKey); final ContentHeaderBody contentHeaderBody = readContentBody(payload); MessageMetaData mmd = new MessageMetaData(publishBody, contentHeaderBody); final MessageHandle<MessageMetaData> handle = store.addMessage(mmd); handle.addContent(payload); final StoredMessage<MessageMetaData> storedMessage = handle.allContentAdded(); return new AMQMessage(storedMessage, connectionReference); } catch (AMQFrameDecodingException | BufferUnderflowException e ) { throw new ConnectionScopedRuntimeException("Error parsing AMQP 0-9-1 message format", e); } }
String to = AMQShortString.toString(messagePublishInfo.getExchange()); if (messagePublishInfo.getRoutingKey() != null) String routingKey = AMQShortString.toString(messagePublishInfo.getRoutingKey()); if (to != null && !"".equals(to))
MessagePublishInfo info = new MessagePublishInfo(exchangeName, immediate, mandatory,