use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_v0_8 method convertMetaData.
private MessageMetaData convertMetaData(final InternalMessage serverMsg, final NamedAddressSpace addressSpace, final String bodyMimeType, final int size) {
MessagePublishInfo publishInfo = createMessagePublishInfo(serverMsg, addressSpace);
final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
props.setAppId(serverMsg.getMessageHeader().getAppId());
props.setContentType(bodyMimeType);
props.setCorrelationId(convertToShortStringForProperty("correlation-id", serverMsg.getMessageHeader().getCorrelationId()));
props.setDeliveryMode(serverMsg.isPersistent() ? BasicContentHeaderProperties.PERSISTENT : BasicContentHeaderProperties.NON_PERSISTENT);
props.setExpiration(serverMsg.getExpiration());
props.setMessageId(convertToOptionalAMQPShortString(serverMsg.getMessageHeader().getMessageId()));
props.setPriority(serverMsg.getMessageHeader().getPriority());
props.setReplyTo(convertToShortStringForProperty("reply-to", getReplyTo(serverMsg, addressSpace)));
props.setTimestamp(serverMsg.getMessageHeader().getTimestamp());
props.setUserId(convertToOptionalAMQPShortString(serverMsg.getMessageHeader().getUserId()));
props.setEncoding(convertToShortStringForProperty("encoding", serverMsg.getMessageHeader().getEncoding()));
Map<String, Object> headerProps = new LinkedHashMap<String, Object>();
for (String headerName : serverMsg.getMessageHeader().getHeaderNames()) {
headerProps.put(headerName, serverMsg.getMessageHeader().getHeader(headerName));
}
try {
props.setHeaders(FieldTable.convertToFieldTable(headerProps));
} catch (IllegalArgumentException | AMQPInvalidClassException e) {
throw new MessageConversionException("Could not convert message from internal to 0-8 because headers conversion failed.", e);
}
final ContentHeaderBody chb = new ContentHeaderBody(props);
chb.setBodySize(size);
return new MessageMetaData(publishInfo, chb, serverMsg.getArrivalTime());
}
use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.
the class MessageFormat_0_9_1 method createMessage.
@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);
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.
the class ProtocolOutputConverterImpl method writeReturn.
@Override
public void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource message, int channelId, int replyCode, AMQShortString replyText) {
AMQBody returnFrame = createEncodedReturnFrame(messagePublishInfo, replyCode, replyText);
writeMessageDelivery(message, header, channelId, returnFrame);
}
use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.
the class ProtocolOutputConverterImpl method createEncodedGetOkBody.
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);
}
use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.
the class MessageMetaDataFactoryTest method createTestMessageMetaData.
private MessageMetaData createTestMessageMetaData() {
final MessagePublishInfo publishBody = new MessagePublishInfo(_exchange, false, false, _routingKey);
final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
props.setContentType(CONTENT_TYPE);
final ContentHeaderBody contentHeaderBody = new ContentHeaderBody(props);
return new MessageMetaData(publishBody, contentHeaderBody, _arrivalTime);
}
Aggregations